Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Help in User Control implemented using Callbacks

Help in User Control implemented using Callbacks

Scheduled Pinned Locked Moved C#
c++javascripthelp
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Neeraj Kr
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups