Solved

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

Posted on 2014-07-20
8
296 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 33

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
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
LVL 33

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 33

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 33

Author Closing Comment

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

Featured Post

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…

770 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