Solved

RadioButton action to be cancled... asp.net c#, javascript

Posted on 2014-07-20
8
297 Views
Last Modified: 2014-07-20
The message in this code fires up ok:
       function handleRollup(myRadio) {
           alert('Monthly option not available at this point.');
           myRadio.value = 2;   <-- this part doesn't work
    }

from:

<asp:Panel ID="optRollup" Class="optRollup" runat="server" OnChange="javascript:updateRollup();" >
<asp:RadioButton ID="RadioButton1" name="Rollup" Text="Monthly" runat="server"  onclick="javascript:handleRollup(this);" value="1" GroupName="Rollup" />&nbsp

<asp:RadioButton ID="RadioButton2"  name="Rollup" Text="YTD" Checked="true" runat="server"  onclick="javascript:handleRollup(this);" value="2"  GroupName="Rollup"/>&nbsp&nbsp
</asp:Panel>

Open in new window


As you can see, there are two options here:

o Monthly
o YTD    <-- default selection

Question 1: How can this function could be modified to keep YTD option selected.
Question 2: Are there options to customize the alert(''); box (title of the box or add icons similar to vbInformatio or vbWarning)?

Thank you.
0
Comment
Question by:Mike Eghtebas
  • 4
  • 4
8 Comments
 
LVL 82

Expert Comment

by:leakim971
ID: 40207682
1: How can this function could be modified to keep YTD option selected.
Don't use the same GroupName

Question 2: Are there options to customize the alert(''); box (title of the box or add icons similar to vbInformatio or vbWarning)?
No, you can't customize it, you need to use a Javascript plugin
0
 
LVL 34

Author Comment

by:Mike Eghtebas
ID: 40207742
leakim971,

re> Don't use the same GroupName

By definition, radio button has to have the same group name. I renamed them as GroupName="Rollup1" and GroupName="Rollup2", the radio buttons stopped working.

I suppose having name="Rollup1" and name="Rollup2" and somehow revising :

myRadio.value = 2;   <-- this part doesn't work

based on name property may work.

Question: Could you do this part if you think it could be the solution?

Thank you,

Mike
0
 
LVL 82

Expert Comment

by:leakim971
ID: 40207747
the radio buttons stopped working

What does that mean?
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 34

Author Comment

by:Mike Eghtebas
ID: 40207760
re:> What does that mean?

Upon start, bey default, upon launching the page, I get:

o Monthly
o YTD    <-- default selection

Now, when I click on Monthly option, I get both of them selected. Unlike a checkbox group, this is not acceptable in radiobutton group. Now I get:

o Monthly   <--  shows selected
o YTD    <-- also shows selected

Any additional click on either of the two options, does't do a thing. They both  remain selected.

Thank you,

Mike
0
 
LVL 82

Expert Comment

by:leakim971
ID: 40207766
you want to set value=2 but not with YTD checked?
0
 
LVL 34

Author Comment

by:Mike Eghtebas
ID: 40207772
I want to exclude Monthly for now.

I do not want to disable the option group because it is a good idea to give them a chance to select Monthly option and read my message. But now, after the message, it has to go back to YTD.

I hope this could help.

Mike
0
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 40207781
yeah else that just made it not logic.

document.getElementById("<%= optRollup.ClientID %>").getElementsByTagName("input")[1].checked = true;

Open in new window


or maybe just :

document.getElementById("<%= RadioButton2.ClientID %>").checked = true;

Open in new window

0
 
LVL 34

Author Closing Comment

by:Mike Eghtebas
ID: 40207816
Thank you very much.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to create an extensible mechanism for linked drop downs.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question