473,748 Members | 2,595 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

asp:RadioButton runat="server" - want to react to click event on client side

I've wasted the whole day trying things and researching, but nothing is
working. I would *greatly* appreciate if someone can give me the
solution to this problem.

I'm using the .NET Framework 2.0 in C# with a Master page and
additional .aspx pages with .cs code-behind pages in Windows XP.

In an .aspx page I have declared a control as follows:
<asp:RadioButto n runat="server" GroupName="rbtn S0"
ID="rbtnS0start " />

I want to do some event-side work whenever this RadioButton is clicked.
I've tried everything I've found, e.g., putting
rbtnS0start.Att ributes.Add("On Click", "rbtnS0start_Cl ick();");
in the .cs file's Page_Load event, and then specifying
<script type="javascrip t">
function rbtnS0start_Cli ck()
alert('test');
</script>
in the asp:Content section of the .aspx file. I get an "error on page"
from IE6 whenever I click that button. I've tried dozens of
combinations of things. (Unfortunately, there is no OnClick attribute
for an asp:RadioButton .)

Can someone *please* give me the code (and where it goes) so that I can
do client-side work when the user clicks an asp:RadioButton control?

Thank you *so much* to anyone who helps!

Jan 24 '07 #1
5 9433
you need to legal javascript syntax to define the function.

<script type="javascrip t">
function rbtnS0start_Cli ck() {
alert('test');
}
</script>
Barry wrote:
I've wasted the whole day trying things and researching, but nothing is
working. I would *greatly* appreciate if someone can give me the
solution to this problem.

I'm using the .NET Framework 2.0 in C# with a Master page and
additional .aspx pages with .cs code-behind pages in Windows XP.

In an .aspx page I have declared a control as follows:
<asp:RadioButto n runat="server" GroupName="rbtn S0"
ID="rbtnS0start " />

I want to do some event-side work whenever this RadioButton is clicked.
I've tried everything I've found, e.g., putting
rbtnS0start.Att ributes.Add("On Click", "rbtnS0start_Cl ick();");
in the .cs file's Page_Load event, and then specifying
<script type="javascrip t">
function rbtnS0start_Cli ck()
alert('test');
</script>
in the asp:Content section of the .aspx file. I get an "error on page"
from IE6 whenever I click that button. I've tried dozens of
combinations of things. (Unfortunately, there is no OnClick attribute
for an asp:RadioButton .)

Can someone *please* give me the code (and where it goes) so that I can
do client-side work when the user clicks an asp:RadioButton control?

Thank you *so much* to anyone who helps!
Jan 24 '07 #2
"bruce barker" <no****@nospam. comwrote in message
news:%2******** ********@TK2MSF TNGP05.phx.gbl. ..
you need to legal javascript syntax to define the function.

<script type="javascrip t">
Or even

<script type="text/javascript">

if you want to be XHTML-compliant...
Jan 25 '07 #3
Oh what a difference a couple of curly braces make! Imagine 9 hours
wasted because I didn't have the curly braces :-(. Thank you both very
much!!

On Jan 24, 8:14 pm, "Mark Rae" <m...@markNOSPA Mrae.comwrote:
"bruce barker" <nos...@nospam. comwrote in messagenews:%2* *************** @TK2MSFTNGP05.p hx.gbl...
you need to legal javascript syntax to define the function.
<script type="javascrip t">Or even

<script type="text/javascript">

if you want to be XHTML-compliant...
Jan 25 '07 #4
Ok, now I want to work with my client controls (instead of just popping
up an alert). For instance when they click rbtnS0start I want the
javascript on the client to set rbtnS1start (another asp:RadioButton )
to be 'checked=true'. I've tried things like: rbtnS1start.Che cked =
true; but apparently that's not right because it doesn't check the
button or execute the rest of my javascript.

Obviously I'm quite new to client-side scripting, so any help/pointers
you can provide would be most appreciated. (Btw, I'm on the clock, so
the sooner someone will help me the better.)

Thank you!!

On Jan 25, 1:17 pm, "Barry" <dys...@gmail.c omwrote:
Oh what a difference a couple of curly braces make! Imagine 9 hours
wasted because I didn't have the curly braces :-(. Thank you both very
much!!

On Jan 24, 8:14 pm, "Mark Rae" <m...@markNOSPA Mrae.comwrote:
"bruce barker" <nos...@nospam. comwrote in messagenews:%2* *************** @TK2MSFTNGP05.p hx.gbl...
you need to legal javascript syntax to define the function.
<script type="javascrip t">Or even
<script type="text/javascript">
if you want to be XHTML-compliant...- Hide quoted text -- Show quoted text -
Jan 26 '07 #5
Well I finally figured out a way to do this. I couldn't get the
document.getEle mentById thing to work, and I'm sure there must be a
more concise way to do this (for example, passing an array) but I don't
know Javascript well enough. At this point, I don't care. I got it to
work, so I'm supplying the complete solution for the other poor souls
out there trying to do the same thing. As a reminder, what this does
is, when the user clicks the asp:RadioButton whose ASP ID is
rbtnS0start, I want the client to run Javascript in the .aspx page so
that the asp:RadioButton s named rbtnS1start thru rbtnS6start
automatically get checked.

In the code-behind page I have this code:
protected void Page_Load(objec t sender, EventArgs e)
{
if (!IsPostBack)
{
rbtnS0start.Att ributes.Add("On Click", "rbtnS0start_Cl ick("
+
rbtnS1start.Cli entID + "," +
rbtnS2start.Cli entID + "," +
rbtnS3start.Cli entID + "," +
rbtnS4start.Cli entID + "," +
rbtnS5start.Cli entID + "," +
rbtnS6start.Cli entID +
");");
}
}

In the .aspx page, I included the following code just before the
</asp:Contenttag (which is the last tag on the page)...
<script type="text/javascript">
function rbtnS0start_Cli ck(b1,b2,b3,b4, b5,b6)
{
b1.checked = true;
b2.checked = true;
b3.checked = true;
b4.checked = true;
b5.checked = true;
b6.checked = true;
}
</script>

Could this have possibly been made any harder to do!!??

On Jan 26, 9:29 am, "Barry" <dys...@gmail.c omwrote:
Ok, now I want to work with my client controls (instead of just popping
up an alert). For instance when they click rbtnS0start I want the
javascript on the client to set rbtnS1start (another asp:RadioButton )
to be 'checked=true'. I've tried things like: rbtnS1start.Che cked =
true; but apparently that's not right because it doesn't check the
button or execute the rest of my javascript.

Obviously I'm quite new to client-side scripting, so any help/pointers
you can provide would be most appreciated. (Btw, I'm on the clock, so
the sooner someone will help me the better.)

Thank you!!

On Jan 25, 1:17 pm, "Barry" <dys...@gmail.c omwrote:
Oh what a difference a couple of curly braces make! Imagine 9 hours
wasted because I didn't have the curly braces :-(. Thank you both very
much!!
On Jan 24, 8:14 pm, "Mark Rae" <m...@markNOSPA Mrae.comwrote:
"bruce barker" <nos...@nospam. comwrote in messagenews:%2* *************** @TK2MSFTNGP05.p hx.gbl...
you need to legal javascript syntax to define the function.
<script type="javascrip t">Or even
<script type="text/javascript">
if you want to be XHTML-compliant...- Hide quoted text -- Show quoted text -- Hide quoted text -- Show quoted text -
Jan 26 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
8403
by: Hazzard | last post by:
I just realized that the code I inherited is using all asp.net server controls (ie. webform controls) and when I try to update textboxes on the client side, I lose the new value of the textbox when submitting the form to update the database. The server doesn't have the client side value any more. It seems to me that as I begin to write the client side javacript code for form validation and client side editing capabilities in order to save...
2
294
by: Lubomir | last post by:
Hi, I have a BoundColumn in a DataGrid: <asp:BoundColumn DataField="lastname" SortExpression="lastname" ReadOnly="True" HeaderText="Last Name"></asp:BoundColumn> Column is sorted. I am wondering why this code is working properly as there is missing the statement runat="server".
4
1667
by: COHENMARVIN | last post by:
I'm a asp programmer starting out with asp.net. I understand that an asp form can post to its own page and that this allows validation of form fields on the server. But suppose all the controls turn out to be valid, and now I want to move to a new page? My form declaration looks like this: <form METHOD="POST" ACTION="sites2.aspx" name="MyForm" runat="server"> This form declaration is on a page called sites1.aspx, but it doesn't post any...
3
5538
by: Jaime Stuardo | last post by:
Hi all... Both controls are server side. The former has more properties. Both may have associated events that are ran at server. Which one are recommended to use? is performance an issue? in what case I can (or must) use the second? If I want an input control that has specific font or color, I can use client side <input> so I'm wondering if there is an advantage to use <input> as
4
6534
by: Ryan | last post by:
Hello, I have a standard HTML button on an aspx web form that I have set to runat server. The button is named reset1 and its tag is as follows: <INPUT id="btnReset1" style="WIDTH: 60px; HEIGHT: 24px" type="reset" value="Reset" name="btnReset1" runat="server"> Using Interdev I then double click the button in design view and in the code behind page (aspx.vb) have the following:
11
2562
by: gunjan.mait | last post by:
hi, i wanted to know the exact use of runat="server" which is being used is ASP.NET why we every time need to use it, even when i want to do the work at client side? How to do simple processings like displaying some message at client side only without hitting server? what is the use of onclick, as we have to use onserverclick always? why it is not possible to do the things without using runat="server" in script?
1
2439
by: mark4asp | last post by:
<form runat="server"automatically adds <divtag to code contained within. Is there a way to stop that? Mixing block-level elements with inline-level elements messes up the HTML becasuse that is invalid for a strict implementation. <spanis in-line-level and <divis block-level. I don't want to mix up <span> and <div> I'm using an <asp:Buttonhere because when it switches to the URL I need to check that the user is in the correct role -...
2
2326
by: Bob | last post by:
Hi, in aspx file, i defined this: <input id="Button2" type="button" value="button" runat="server" onclick="klik()"/> This 'onclick' event is a clientclick (starting the Javascript function "klik()" ). I want to do a 'server onclick', just like the <asp:Buttoncontrol, but it
4
13308
by: Chris | last post by:
Hi, i 'm experimenting with postback and i tried that with a button server control and an Html input button but with runat="server". The button server control causes a postback, but not the Html input button with runat="server". Can someone explain me why (because it's running on the server)? Thanks
0
8991
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8830
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9370
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9321
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9247
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8242
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6796
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4602
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4874
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.