This is a migrated thread and some comments may be shown as answers.

Rad Button not working with onClientClicked

1 Answer 745 Views
Button
This is a migrated thread and some comments may be shown as answers.
Danny
Top achievements
Rank 1
Danny asked on 05 Apr 2012, 11:44 PM
I have an application with a signin page. On the signin page, I load Javascript to get the UTCOffset from the clients browser. 

When I use the standard asp.net button it works fine, when I try to use the radbutton. The button basically does not work. Not only just the javascript appear not to fire. It appears the page is not reloaded after the postback.

 I was using the OnClientClickproperty, but that is not an option for the RadButton. I have tried OnClientClicked and OnClientClicking properties. 




            <script language="javascript" type="text/javascript">


                //logic for this found  http://forums.asp.net/t/1064203.aspx?PageIndex=2
                function GetClientUtcOffset(frm) {
                    var d = new Date();


                    appendParam('uDate', d.getTimezoneOffset(), frm);
                }


                function appendParam(pName, pVal, tForm) {
                    var n = document.createElement('input');
                    n.setAttribute('name', pName);
                    n.setAttribute('type', 'hidden');
                    n.setAttribute('value', pVal);


                    var f = document.getElementById(tForm);


                    if (!f) {
                        // When using single Form page or not specifying Form
                        f = document.forms[0];
                    }


                    // append the new Element to the Form!
                    f.appendChild(n);
                }
        </script> 




        protected void Page_Load(object sender, EventArgs e)
        {
             btnSignin.OnClientClicked = "javascript:GetClientUtcOffset()";
        }

        protected void btnSignin_Click(object sender, EventArgs e)
        {
            String comparePassword = "";
            String firstName = "";
            Int32 userId = 0;




         //   Session["UtcOffsetMins"] = Server.HtmlDecode(Request["uDate"]).Split(',')[0];
          //  txtEmailAddress.Text = Server.HtmlDecode(Request["uDate"]).Split(',')[0];
            txtEmailAddress.Text = "hello"; // even this does not work when I register JS on Page Load. 
          
        }


1 Answer, 1 is accepted

Sort by
0
Slav
Telerik team
answered on 09 Apr 2012, 12:05 PM
Hi Danny,

As you have already found out the RadButton control has two client-side events that are fired on a button click - OnClientClicking and OnClientClicked. The encountered problem is caused by the values, passed to these properties. If you want to set an event handler for these or any of the other client-side events, you should specify only the name of the handler function, as shown in this helps article.

In case you want to pass parameters to the attached handler method, you can use the approaches, described in this Code Library article.

Feel free to contact us again if you encounter more difficulties.

Greetings,
Slav
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Button
Asked by
Danny
Top achievements
Rank 1
Answers by
Slav
Telerik team
Share this question
or