?
Solved

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

Posted on 2014-07-20
8
Medium Priority
?
302 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 2000 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

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

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

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
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…
Suggested Courses

762 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