Mono Support Can't figure out Rating 

Viewed 29832 time(s), 13 post(s), 12/19/2011 5:41:15 PM - by grant.stone007
12/27/2011 10:59:01 AM
15993 Reputation 2214 Total posts

Hi,

you did everything correctly the problem still remains because this isn't the problem related to the MessageDetails. To get these two controls to co-operate try to put the following code just below the base.OnInit call as per below sample:

protected override void OnInit(EventArgs e)
{
  base.Rating += new EventHandler<RatingEventArgs>(myRating);
  base.Rated += new EventHandler<MonoSoftware.Core.EventArgs<decimal>>(myRated);
  base.OnInit(e);
  ....
  rpt.DataSource = RatingBusinessLogicLayer.GetRatingCollection(ParentEntityId, ParentEntityType, false, 15);
  rpt.DataBind();
  ....
}

Let me know if that did the trick.

Regards

11
12/28/2011 2:55:34 AM
647 Reputation 69 Total posts

I have devised a solution by taking a different approach. I customized the MessageCreate.ascx and some class overrides as opposed to the custom usercontrol I was attempting before. See my markup and code below. This works perfectly using the standard MonoXRating.ascx.

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="myMessageDetails.ascx.cs" Inherits="myMessageDetails" %>
...

<%@ Register TagPrefix="MonoX" TagName="Rating" Src="/MonoX/Controls/MonoXRating.ascx" %>
...

<
asp:Panel runat="server" ID="pnlContainer">
    <div class="input-form reply-message">
    <dl>
    <dd>
 
<MonoX:Rating ID="ctlRating" runat="server"
    ParentEntityType="Message"
    OnRating="myOnRating"
    OnRated="myOnRated"
    ShowRatingHistory="true"
/>
<br />
        <asp:Label ID="lblMessage" runat="server" AssociatedControlID="txtMessage"></asp:Label>
        <asp:TextBox ID="txtMessage" Rows="8" TextMode="MultiLine" runat="server"></asp:TextBox>
    </dd>


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Data;
 
using MonoSoftware.MonoX.Controls;
using MonoSoftware.MonoX.Repositories;
using MonoSoftware.MonoX.DAL.EntityClasses;
using MonoSoftware.MonoX.Utilities;
 
using MonoSoftware.MonoX;
using MonoSoftware.MonoX.API;
using System.Configuration;
using Telerik.Web.UI;
 
/// <summary>
/// Summary description for myMessageDetails
/// </summary>
public partial class myMessageDetails : MonoSoftware.MonoX.ModuleGallery.SocialNetworking.MessageDetails
{
    public myMessageDetails()
    {
        //
        // TODO: Add constructor logic here
        //
    }
 
    protected override void OnPreRender(EventArgs e)
    {
        base.OnPreRender(e);
            MonoSoftware.MonoX.Controls.MonoXRating r (MonoSoftware.MonoX.Controls.MonoXRating)this.FindControl("ctlRating");
      
r.ParentEntityId = this.MessageId;
      r.DataBind();   
    }
 
    protected void myOnRating(object sender, EventArgs e)
    {
        MonoSoftware.MonoX.Controls.MonoXRating r = (MonoSoftware.MonoX.Controls.MonoXRating)this.FindControl("ctlRating");
        r.ParentEntityId = this.MessageId;
    }
 
    protected void myOnRated(object sender, MonoSoftware.Core.EventArgs<decimal> e)
    {
        //e.Value has the rating <decimal>.
   //do something based upon the rating...
    
}
}

12
12/28/2011 11:32:34 AM
15993 Reputation 2214 Total posts

Hi,

It's great to hear that you have found the solution that suites you, let us know if you need anything else.

Regards

13
1 2
This is a demo site for MonoX. Please visit Mono Software for more info.