Help in User Control implemented using Callbacks
-
Hi, I am creating a 5 star rating control using callbacks. I am not able to send the value to the parent page and then save it. When I try to capture the click event of the image, I guess multiple events occur and then I loose the actual value. The actual value does not persists. I have used five image controls and One hiddenField named 'hdn' and have written javascript functions for handling the OnMouseOver, OnMouseOut and Click Event. The functions are s follows: --------Image Click Event---------- function onImgClick(strVal) { var countRec; var imgName; var message = strVal + ":" + "Click"; var context = "Click"; CallServer(message, context); } ------------------------------------ ----------OnMouseOver-------------- function callSwapImage(strVal) { var countRec; var imgName; for (countRec = 1; countRec<=parseInt(strVal); countRec++) { imgName = "imgStar" + String(countRec); document.images[imgName].src = "images/starGold.gif"; } } ---------OnMouseOut------------ function callSwapRedo() { var message = document.getElementById("rc1_hdn").value + ":" + "Redo"; var context = "Redo"; CallServer(message, context); } ------------------------------- In the code behind file of the user control I have written the following code in the Page_Load Event 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); HiddenField hdn = new HiddenField(); } For the RaiseCallbackEvent I have written public void RaiseCallbackEvent(string eventArgument) { string[] remCount = new string[2]; if (Rated != null) { if (eventArgument != "") { remCount = eventArgument.Split(':'); if (remCount[1] == "Click") { EventArgs args = new EventArgs(); Rated(this, args); } } if (hdn.Value.ToString() == "" && remCount[0