Javascript - Disabled Radio Button Losing Value After Postback

Feb 14, 2011

I have two radio buttons that are disabled with javascript when the page loads. RadioButton1 is checked by default. When I click the button to do a postback, the RadioButton1 is no longer checked.

Here's my code sample. The code behind is empty.

<asp:RadioButton ID="RadioButton1" runat="server" GroupName="group" Checked="true"/>
<asp:RadioButton ID="RadioButton2" runat="server" GroupName="group" />
<asp:Button ID="Button1" runat="server" Text="Button"></asp:Button>
<script type="text/javascript">
window.onload = function () {
var RadioButton1 = document.getElementById('<%= RadioButton1.ClientID %>');
var RadioButton2 = document.getElementById('<%= RadioButton2.ClientID %>');
RadioButton1.disabled = true;
RadioButton2.disabled = true;
};
</script>

View 4 Replies


Similar Messages:

Web Forms :: Postback Using Javascript For Radio Button List?

Oct 5, 2010

My current structure:

1. An asp.net radio-button list with autopostback = true. The radio-button list has 2 items - Yes and No.

2. An asp panel that has 2 textbox.

Current behaviour:

When the user clicks on the radio-button list (i.e. Yes), the panel is made visible.

My clients wants the same functionality without the page refresh (i.e. the postback).

View 4 Replies

IE Not Printing Disabled Radio Button's Selection?

Sep 24, 2010

I have a set of radio buttons that are all disabled, and one of them is selected. In IE8, when I print the web page, the selected radio button is not showing as selected. However, this works fine in FireFox.

View 1 Replies

Web Forms :: Clicking Radio Button In Web Control Causes All Other Web Control Radio Buttons To Fire Postback?

Feb 8, 2010

I have a web application that shows a page containing between 6 and 20 AJAX UpdatePanels, contained with Custom Web (.ascx) Controls.

You can see an example of such a page here:

[URL]

The problem I'm getting is that when the user FIRST clicks any of the radio-buttons on any of the controls in the page, ALL the radio buttons that have an active selection ALSO fire an rb_CheckChanged event (see application log below). On subsequent radio-button
clicks, only that RB fires the event (as expected).

This behaviour is having a dramatic impact on performance. The page loads quickly, and a "normal" RB click provides an AJAX update correctly within 1 second. The problematic first RB click, however, takes up to SIX seconds to process, which is unacceptable from a user experience standpoint.

Developed in VS.NET 2008, ASP.NET 3.5. Also I converted the "Web Site" solution to a "Web Application" (pre-compiled) and got the same performance (still too slow). Release builds run only marginally faster than debug builds.

Why would a single RB selection change cause all RB's that have a "selection" set on them to also fire? (The "selection" is determined through database settings every time the control is populated, which is called from within the parent page control's Page_Load function. This selection is determined also at first page load, since all the controls get populated then, so why would the clicking of an RB cause them all to fire an event, and only once? That's what I don't get...)

Not sure if this is an AJAX issue, or general ASP.NET UI issue, so I'm posting in two forums on this one.

View 5 Replies

Checkbox Losing Value On Postback Due To JavaScript / JQuery Array?

Feb 1, 2011

I have a simple asp:RadioButtonList within a form tag but for some reason it isn't keeping it's value on postback

Here's what I've got

[code]....

View 3 Replies

AJAX :: Losing Javascript Events On Async Postback?

Apr 27, 2010

I am creating a ASP.Net server control to manage locations. The control is a composite control containing several text-boxes, labels, and a link button. I use the AJAX Control Toolkit to provide a modal popup which contains a Bing map. All the Javascript is in its own file and used as an embedded web resource.

The link button is what opens the modal popup. It also needs to call a Javascript function that initializes the Bing map (onclick = "GetMap();"). There are instances when this server control is placed within an Update Panel (and there is no way to avoid this). When in an Update Panel the link button loses its onclick event. I understand that this is because during an async postback the portion of the DOM that defines the content of the Update Panel is thrown out and reinitialized, resulting in the event breaking. When the control is not in an Update Panel everything works as intended.

I have tried registering events on Page.Load and Page.Init, like so:

[Code]....

I have also tried flat out writing the function call to the page:

[Code]....

I have put breakpoints on the lines inside each delegate and they do not get hit. I am not aware of any special way to register events of a composite control's child control or the Page.Load/Page.Init events when being done inside a server control. Is there some special way to register these events? (Note: Both those code blocks above are in my CreateChildControls() method)

Below is the GetMap() Javascript function. As you can see it is pretty straight forward.

[Code]....

View 3 Replies

Button Eventhandler Doesn't Fire When Button Disabled With JavaScript?

Apr 9, 2010

standard webcontrol:
<asp:Button ID="cb_btnSubmitData" Text="Submit data" OnClick="SubmitData_Click" runat="server" />
added this in the Page_Load eventhandler
this.cb_btnSubmitData.Attributes.Add("onclick", "addTextToLabel('message', '" + this.cb_btnSubmitData.ClientID + "');return true;");

and this is the javascript that is executed when the button is pressed:

<script type="text/javascript">

View 5 Replies

C# - Radio Button Loses Value On Postback?

May 3, 2010

I have a set of radio buttons for "yes" and "no" values which have a name="choice". "yes" is checked by default. They're both runat="server". I read the choice on postback like below. It works perfectly fine as long as the validation doesn't fail. For example, if I select "no" and validation fails on postback, I still see "no" selected. But if I submit the form after correcting everything, the value read is "yes" on server side! Is this a bug in .net, and if so, how do i fix this?

foreach (string key in Request.Form.AllKeys)
{
if (key.EndsWith("choice"))
return Request.Form[key] == "yes";
}

View 1 Replies

Javascript - Disabled Link Button Still Submitting In Webform?

Dec 15, 2010

I'm trying to disable a link button to prevent the user from submitting several times.

I've seen many questions like this here on SO, most people suggest the following javascript:

button.disabled = true or button.disabled = 'disabled'

Which indeed disables the button (the button is greyed out), but the problem is that it's still clickable, and still submits!!

Here is my stripped down code:

function ValidateButton(button){
// some other code
button.disabled = true;
button.value = 'Processing...';
}
<asp:LinkButton Text="Submit" ID="btnSubmit" runat="server" onclick="btnSubmitRow_Click" OnClientClick="return ValidateButton(this);"/>

Why is the button still clickable, and submits after being disabled ? The button text is still "Submit" not "Processing...', why?

View 5 Replies

Disabled Submit Button & Javascript Error Outside Update Panel?

Jun 2, 2010

[URL]

I'm using the code the above and running into an error i can't quite figure out. Maybe its something simple or maybe it's something that can't be done. Not sure.

I created a user control (button) that references a javascript file like this:

string url = ResolveClientUrl("./Scripts/main.js");
function SubmitButton_Click(e) {
try {
var src = typeof (event) != 'undefined' ? event.srcElement : e.target;

[Code]....

The error that i am running into is this:

The buttons in the update panel work everytime without any problems. When i click a button in the update panel and then click a button outside the update panel it chockes on this line of the above javascript.

src.aspnet_onclick();

The value of aspnet_click() is 'SubmitButton_Click(e)'. This is incorrect which causes it to choke.

The value should be 'onclick(event)'

For some reason when click the button inside the update panel and then the button outside the update panel causes this javascript error but I am not sure why the aspnet_onclick() is incorrect.

View 1 Replies

AJAX :: Textbox Postback Causing Radio Button List To Lose Selection?

May 27, 2010

This is likely a n00b question, but I can't seem to find any info on how to solve it. Here's the scenario:

I have a Textbox and a RadioButtonList in an UpdatePanel, both with AutoPostBack turned on (they need to be, can't turn it off on the text box))

The user enters some text in to the textbox, then clicks one of the Items in the radio button list.

Because the textbox post back is executing, the radio button is losing the value that the user selected.

How can I workaround this?

View 4 Replies

Web Forms :: Javascript Error Message Shows Up Even Though The Delete Button Is Disabled?

Dec 21, 2010

when the link button is disabled the javascript error message comesup just by clicking it.When it is disabled it shouldnt come up not sure why it is coming up.

asp:LinkButton
ID="DeleteCategoryLink"
CssClass="link"
CausesValidation="false"
runat="server"
Text="Delete"
OnClientClick="javascript:return
confirm('Are you sure you want to do this?');"
/>

View 2 Replies

Radio Button List Item Using Javascript

Oct 27, 2010

I am having one radio button list.

<asp:RadioButtonList ID="rdHealthCleared" runat="server"
CssClass="radiobtn" AutoPostBack="true" OnClick="showRadioCheckBox()"
CausesValidation="false" CellPadding="0" CellSpacing="0" Width="275px">
<asp:ListItem id="rdNotCleared" runat="server" Text="Not Cleared" Value="1"/>
<asp:ListItem id="rdPending" runat="server" Text="Pending further Info from Applicant" Value="2"/>
<asp:ListItem id="rdCleared" runat="server" Text="Cleared" Value="3" />
</asp:RadioButtonList>

I am using three check boxes. If i click first radio button list item, the first check box need to show. In the same scenario for another two radio button list items and checkboxes. How can we done in javascript. i call it the onclick function and put it node value for this condition but when in alert the node value is giving null. this is my java script code.

var uxNotClearedObj = document.getElementById('uxOHCNotCleared2');
//alert(uxNotClearedObj);
var uxPendingObj = document.getElementById('uxOHCPending2');
// alert(uxPendingObj);
var uxClearedObj =document.getElementById('uxOHCCleared2');
//alert(uxClearedObj);
var rdPendingObj = document.getElementById('rdPending');
// alert(rdPendingObj);
var rdClearedObj = document.getElementById('rdCleared');
var rdNotClearedObj = document.getElementById('rdNotCleared');
// alert(rdClearedObj);
var rdHealthClearedObj = document.getElementById('rdHealthCleared');.....................

View 2 Replies

Javascript To Check Against Radio Button Selection?

Apr 1, 2010

I'm trying to write a javascript to check if the 5th element in the radiobutton list is selected then:

1. alert 'enter an amount' if the txtbox is empty

2. alert 'amount must be greater than 10' if the txtbox value is less than 10

My code is shown below, but I guess I'm missing something because the code didn't executed.

[code]......

View 14 Replies

How To Disable A Certain Radio Button In A RadioButtonList In Javascript

Aug 24, 2010

I'm at my wit's end when it comes to this. JavaScript definitely isn't my strong suit and I've been trying to google for a solution. Here's the code I have:

[Code]....

What I want to do is whenever you click a radio button on the Group1Most RadionButtonList, it will disable the corresponding radio button on the Group1Least RadioButtonList. The problem is I can't figure out how to select an individual radio button within the RadioButtonList.

View 3 Replies

Javascript - Accessing Value From ExtJS Radio Button?

Sep 22, 2010

So I declare an ExtJS radio button object like this:

.AddExtObject("{xtype:'radiogroup', ref:'../AndOr', defaults:{name:'rdo-payee2'}, width:120, items:[{boxLabel:'And', checked:true, inputValue:'and'},{boxLabel:'Or', inputValue:'or'}]}")

When I do this:

if (checkWin.Payee2.AndOr.getValue() == 'and') {
fundingRec.set('IsPayee2RequiredToSign', '1');
} else {

[code]...

View 1 Replies

Web Forms :: Handle Radio Button Selection Using JavaScript?

Feb 14, 2010

Is their a way to handle the event of an Asp.net radio button being selected in an Aspx web form using Java Script? Suppose I have 3 radio buttons on a web form and for each radio button selected there would be a Java Script method that would be called for each different radio button selected?

how to do this using Java Script and Asp.net radio style buttons?

Below is an example of how I currently doing my solution using Asp.net and a C# event handler.

[code]....

View 3 Replies

Web Forms :: How To Select Only One Radio Button And Radio Button Validation

Mar 2, 2011

I've two radio buttons in my web site for selecting sex, one s for Male & another s for Female, Problem is during the Run time, I was able to select both the Radio Buttons, but as per my need i should select only one radio button. And i should perform validation Wn user not selected even one radio button i should show the error msg, like " select sex "

View 8 Replies

Web Forms :: Radio Button Checked Changed Event Not Firing With Onclick Javascript Function?

Dec 4, 2010

I have used below code.

<asp:RadioButton GroupName="grpAssoc" ID="rbtEvery" runat="server" Text="Everyone"
onclick="return doChangeAssociationType(0);" AutoPostBack="True" oncheckedchanged="rbtEvery_CheckedChanged"
/>
but oncheckedchanged="rbtEvery_CheckedChanged" not firing even javascript function returns true

How to fire the event?

View 2 Replies

Custom Server Controls :: Custom Radio Button Loses State After Postback?

Mar 24, 2010

I have a custom radiobutton and it renders fine but loses state after postback.

How can it be modified?

[Code]....

View 1 Replies

Looping Through Each Group Of Radio Buttons And Getting The Text Of The Selected Radio Button?

Mar 21, 2010

i have a table which looks something like the following

<table id="Table1" border="0">
<tr>
<td><b>1.</b> Question 1</td>[code]....

how do i go about looping through each group of radio buttons and getting the text of the selected radio button ?the code displayed above is created dynamically ... in my aspx file i have the following code

<asp:Table ID="Table1" runat="server">
</asp:Table>

View 3 Replies

Checking A Radio Button With JQuery When Radio Button Is Runat="server"?

Aug 10, 2010

Using jQuery I want to be able to click an element which will also checks it's related radio button. I had this working fine until we had to add runat="server" to the radio buttons.When I apply this it prevents my jQuery function from working how to get round it, heres a simplified version of the code:HTML

<input type="radio" runat="server" id="sector1Radio" name="SectorGroup" title="Sector1" />

jQuery

$('#SomethingElse').click(function() {
$('input[title=Sector1]').attr('checked','checked');
});

I've found out that when its converted to a .net control instead of checked="checked" (as it would be usually) it is just Checked, so I changed that but on inspecting the DOM in multiple browsers, none of my radio buttons are being checked(Are there any other ways I can use jQuery to check a radio button that has runat="server"?

View 9 Replies

How To Get Specified Space Between Radio Button And The Radio Button Text

Apr 4, 2011

I have the following code<asp:RadioButton runat="server" Text="Male"></asp:RadioButton>I want a gap between the radio button and the radio button text, I made the following changes in the text field(prefixed a space) Text=" Male". However, I don't feel this is the most efficient way.

View 1 Replies

C# - Losing The Session After The Postback?

Sep 1, 2010

I have been using session variables in my asp.net application for passing the next property:

[DefaultValue(true)]
public bool IsModificationMode
{
get
{
return (bool)Session["ModificationMode"];
}
set { Session["ModificationMode"] = value; }
}

In the PageLoad, I set it's value.

Now after the Postback, I am losing it's value having a a NullReferenceException

View 4 Replies

Losing Textbox Value On Postback?

Jun 9, 2010

In a page I have a link; clicking on it opens a dialog and sets a textbox value for that dialog.

However, once I click on submit in that dialog, the textbox value is null.

Link:

<a href="#" onclick="javascript:expand('https://me.yahoo.com');
jQuery('#openiddialog').dialog('open'); return false;">
<img id="yahoo" class="spacehw" src="/Content/Images/spacer.gif" /></a>

[Code].....

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved