Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Not same events on HTML side and code-behind

Status
Not open for further replies.

vilrbn

Programmer
Oct 29, 2002
105
0
0
FR
Hello,

I want to use an HTML radio button instead of an ASP one.
This choice because there are an onclick() and onserverclick() events,I want to call a Javascript function and execute VB code.

input id=&quot;rblChoice1&quot; onclick=&quot;showHideTable('Table1','Table2');&quot; type=&quot;radio&quot; value=&quot;rblChoice1&quot; name=&quot;RadioGroup&quot; runat=&quot;server&quot; onserverclick=&quot;rblChoice1_ServerClick&quot;>Choice1<br>
<input id=&quot;rblChoice2&quot; onclick=&quot;showHideTable('Table2','Table1');&quot; type=&quot;radio&quot; value=&quot;rblChoice2&quot; name=&quot;RadioGroup&quot; runat=&quot;server&quot; onserverclick=&quot;rblChoice2_ServerClick&quot;>Choice2

My problem is that on code-behind, I cannot find the onserverclick event, but ONLY a onserverchange !!

Private Sub rblChoice1_ServerChange(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rblChoice1.ServerChange
End Sub

How can I solve this problem ?
 
Codebehind only supports server-side code, not client-side (such as JavaScript).

I would suggest using an ASP.NET radio button and adding a JavaScript event to it. The ASP.NET radio button has the &quot;CheckedChanged&quot; event that you can stick your VB code in.

As for JavaSript, the ASP.NET controls fully support adding client-side code to them. You add client-side code with the following (sorry... i don't code in vb.net, so this is in c#):

[RadioButtonObject].Attributes.Add([event],[function]);

For example, if you want to make sure that the user definitely wants to make this selection, you would put:

[RadioButtonObject].Attributes.Add(&quot;onClick&quot;, &quot;return confirm('You better be damn sho' you wanna do this...');&quot;);

Hope that helps =D

-----------------------------------------------
&quot;The night sky over the planet Krikkit is the least interesting sight in the entire universe.&quot;
-Hitch Hiker's Guide To The Galaxy
 
It's working fine !!
Many thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top