5 Star Rating Control using CallBack
-
I am creating a 5 star rating control. For this I have created a user control with the Callback functionality. When I implement the usercontrol on an aspx page, I want that the label control to populate the value of the image that was clicked. But, when I debug my application, it shows that the label control has the value and it does not show on the page. Following is the code I am using for the User Control: public event System.Web.UI.WebControls.CommandEventHandler Rater; protected void Page_Load(object sender, EventArgs e) { sCallBackFunctionInvocation = Page.ClientScript.GetCallbackEventReference(this, "message", "ShowSuccess", "context"); String callbackScript; callbackScript = "function CallServer(message, context)" + "{ " + sCallBackFunctionInvocation + ";}"; Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "CallServer", callbackScript, true); } public void RaiseCallbackEvent(string eventArgument) { if (hdn.Value.ToString() == "" && (eventArgument == "0" || eventArgument == string.Empty)) { returnValue = "0"; totChecked = returnValue; hdn.Value = returnValue; } else { returnValue = eventArgument; hdn.Value = returnValue; totChecked = returnValue; CommandEventArgs args = new CommandEventArgs("Rated", hdn.Value.ToString()); Rater(this, args); } } public string GetCallbackResult() { return returnValue; } The following code is used for aspx page protected void Page_Load(object sender, EventArgs e) { rc1.Rater += new CommandEventHandler(rc_Rater); } private void rc_Rater(object sender, CommandEventArgs e) { RatingControl rc = new RatingControl(); lbl.Text = e.CommandArgument.ToString(); }
-----Have A Nice Day-----
-
I am creating a 5 star rating control. For this I have created a user control with the Callback functionality. When I implement the usercontrol on an aspx page, I want that the label control to populate the value of the image that was clicked. But, when I debug my application, it shows that the label control has the value and it does not show on the page. Following is the code I am using for the User Control: public event System.Web.UI.WebControls.CommandEventHandler Rater; protected void Page_Load(object sender, EventArgs e) { sCallBackFunctionInvocation = Page.ClientScript.GetCallbackEventReference(this, "message", "ShowSuccess", "context"); String callbackScript; callbackScript = "function CallServer(message, context)" + "{ " + sCallBackFunctionInvocation + ";}"; Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "CallServer", callbackScript, true); } public void RaiseCallbackEvent(string eventArgument) { if (hdn.Value.ToString() == "" && (eventArgument == "0" || eventArgument == string.Empty)) { returnValue = "0"; totChecked = returnValue; hdn.Value = returnValue; } else { returnValue = eventArgument; hdn.Value = returnValue; totChecked = returnValue; CommandEventArgs args = new CommandEventArgs("Rated", hdn.Value.ToString()); Rater(this, args); } } public string GetCallbackResult() { return returnValue; } The following code is used for aspx page protected void Page_Load(object sender, EventArgs e) { rc1.Rater += new CommandEventHandler(rc_Rater); } private void rc_Rater(object sender, CommandEventArgs e) { RatingControl rc = new RatingControl(); lbl.Text = e.CommandArgument.ToString(); }
-----Have A Nice Day-----