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. Web Development
  3. ASP.NET
  4. Javascript call

Javascript call

Scheduled Pinned Locked Moved ASP.NET
csharpjavascripthelp
4 Posts 3 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.
  • A Offline
    A Offline
    AB7771
    wrote on last edited by
    #1

    Hi Guys, i am a bit new to ASP .net web development. I have created a user control and placed some radio buttons, now i want to call a javascript function on the OnCheckedChanged event of the radio button. I googled but to no use. Also on my web page if i try to call a javascript it gives me error. Can anyone please tell me the correct way to call javascript in both the cases. Thanks in advance,

    Thanks & Regards, Pramod "Everyone is a genius at least once a year"

    N N 2 Replies Last reply
    0
    • A AB7771

      Hi Guys, i am a bit new to ASP .net web development. I have created a user control and placed some radio buttons, now i want to call a javascript function on the OnCheckedChanged event of the radio button. I googled but to no use. Also on my web page if i try to call a javascript it gives me error. Can anyone please tell me the correct way to call javascript in both the cases. Thanks in advance,

      Thanks & Regards, Pramod "Everyone is a genius at least once a year"

      N Offline
      N Offline
      Niladri_Biswas
      wrote on last edited by
      #2

      Solution for OnCheckedChanged event of the radio button. check with ClientScript.RegisterClientScriptBlock e.g.[ some pseudo code]

      public void ShowMessage(string input) {
      string strScript = String.Empty;
      strScript =@"<script language=javascript> ";
      strScript = strScript + "alert('"+input+"')";
      strScript = strScript + @"</script>";
      RegisterClientScriptBlock("clientScript", strScript);
      }

      protected void rdButton_OnCheckedChanged(object sender, EventArgs e)
      {
      ShowMessage("Niladri Showed a way to solve the problem");
      }

      Check for the next part, add <pre><script language="javascript" type="text/javascript"></pre> If not you are making any mistake it is guarented to work. Vote please :)

      Niladri Biswas

      1 Reply Last reply
      0
      • A AB7771

        Hi Guys, i am a bit new to ASP .net web development. I have created a user control and placed some radio buttons, now i want to call a javascript function on the OnCheckedChanged event of the radio button. I googled but to no use. Also on my web page if i try to call a javascript it gives me error. Can anyone please tell me the correct way to call javascript in both the cases. Thanks in advance,

        Thanks & Regards, Pramod "Everyone is a genius at least once a year"

        N Offline
        N Offline
        N a v a n e e t h
        wrote on last edited by
        #3

        Yadav Pramod wrote:

        now i want to call a javascript function on the OnCheckedChanged event of the radio button.

        OnCheckedChanged is a server side event and fires only when AutoPostBack is turned on. So hooking a JS function from here is pointless. I guess you want to call a JS function when someone clicks on the CheckBox, right? Use the Attributes[^] property to add a onClick attribute. Something like YourCheckBox.Attributes.Add("onClick","JsFunction();") Do this on the page load, so that your checkbox renders with this attribute and JsFunction() will get called when user clicks on the checkbox. :)

        Navaneeth How to use google | Ask smart questions

        A 1 Reply Last reply
        0
        • N N a v a n e e t h

          Yadav Pramod wrote:

          now i want to call a javascript function on the OnCheckedChanged event of the radio button.

          OnCheckedChanged is a server side event and fires only when AutoPostBack is turned on. So hooking a JS function from here is pointless. I guess you want to call a JS function when someone clicks on the CheckBox, right? Use the Attributes[^] property to add a onClick attribute. Something like YourCheckBox.Attributes.Add("onClick","JsFunction();") Do this on the page load, so that your checkbox renders with this attribute and JsFunction() will get called when user clicks on the checkbox. :)

          Navaneeth How to use google | Ask smart questions

          A Offline
          A Offline
          AB7771
          wrote on last edited by
          #4

          Thanks Navaneeth, Have u ever worked on user controls and AJAX toolkit?

          Thanks & Regards, Pramod "Everyone is a genius at least once a year"

          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