Solved

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

Posted on 2014-07-20
8
295 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
I need help displaying 2 models in one view in my MVC.Net application with C# code behind 5 33
Angular JS Route 3 47
Entity Framework 7 30
jQuery Validate 4 16
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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…

911 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now