Not able to un-check or check my checkbox control using Java Script with .aspx

Hello, I am trying to programatticaly un-check a checkbox on my web form using Java script. This is in an asp.net web form. Can someone spot what is wrong here? Below is the web form that can easily be cut and pasted into visual studio in order for you to see what is going on.

 

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Sampler._Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script type="text/javascript">

function handleControls()

{

alert(
'One');

var rdoEnabledState = document.getElementById("<%= rbtnOne.ClientID %>");

var rdoDisabledState = document.getElementById("<%= rbtnTwo.ClientID %>");var chkBoxImmediate = document.getElementById("<%= chkBoxQuickIt.ClientID %>");

 

if(rdoEnabledState.checked==true)

{

alert('Wham');

chkBoxImmediate.Checked = true;

chkBoxImmediate.Checked=false;

Response.Write("You Selected: Asp.Net");

}

if(rdoDisabledState.checked==true)

{

alert(
'Bam');

chkBoxImmediate.Checked = false;

chkBoxImmediate.Checked=false;

}

}

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">

<title>Untitled Page</title>

</head>

<body>

 

<form id="form1" runat="server">

<div>

<div class="fieldsetContent">

<table width="100%" cellpadding="0" cellspacing="10" class="formTable">

 

<tr>

<td>

<asp:RadioButton ID="rbtnOne" runat="server" Text="Test 1" GroupName="Software" onclick="handleControls()" />

</td>

</tr>

<tr>

<td>

<asp:RadioButton ID="rbtnTwo" runat="server" Text="Test 2" GroupName="Software" onclick="handleControls()" />

</td>

</tr>

<tr>

<td>

<asp:CheckBox ID="chkBoxQuickIt" runat="server" Text="My check box" Checked="True" />

</td>

</tr>

</div>

</form>

</body>

</html>

0
brgdotnet
1/29/2009 11:43:20 PM
asp.net.client-side 24353 articles. 1 followers. Follow

3 Replies
821 Views

Similar Articles

[PageSpeed] 55

Java Script is case sestive. It is "checked"

chkBoxImmediate.Checked = true;  ---> chkBoxImmediate.checked = true;



My Blog


"Don't be afraid to be wrong; otherwise you'll never be right."
0
budugu
1/30/2009 1:41:47 AM
Javascript is case sensitive. Replace .Checked with .checked
C# <---> VB.Net Translator
0
MetalAsp
1/30/2009 1:42:09 AM

if you are using javascript

Response.Write("You Selected: Asp.Net");  wont work

make it document.write("You Selected: Asp.Net");


Diseirra
Mark it as an answer, if it helped you anyhow...
0
diseirra
1/30/2009 7:30:49 AM
Reply:

Similar Artilces:

checking checkbox is checked or not using checkbox.checked
Hi,my checkbox is<asp:CheckBox ID="Chkcity" runat="server" Text="My own city"  OnCheckedChanged="EventHandler"/>code behind: Private Sub Chkcity_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Chkcity.CheckedChangedif (Chkcity ...............)end if End SubERROR    'EventHandler' is not a member of 'ASP.bpoaddjob_aspx'.    Please Mark the post as "ANSWER" if it helps you I think it should be like this:<asp:CheckBox ID="Chkcity"...

Checking All CheckBoxes in a GridView Using Client-Side Script
Hi; I have  checkbox column in gridview and a checkbox in header gridview. i write down code: Dim checkbox As CheckBox = GridView2.HeaderRow.FindControl("HeaderCheckbox")checkbox.Attributes("onclick") = "ChangeAllCheckBoxStates(this.checked);"  For Each row As GridViewRow In GridView2.Rows Dim a As CheckBox = row.Cells(0).FindControl("CheckBox2") If row.RowType = DataControlRowType.DataRow ThenClientScript.RegisterArrayDeclaration("CheckboxIDs", String.Concat("'", a.ClientID, "'")) End IfNe...

Java script popup dialog box when a check box control is checked. How to do with a check box?
 I have a checkbox named cbxGetInfo. If someone checks the checkbox, I want to a popup dialog box confirming the action that will be done because of the checkbox being checked. A few months ago, I used a Java Script popup dialog box for a confirmation on an action being done. Now I need to figure out how to do this for when a check box has been checked. Can someone tell me what I am doing wrong. Here is the code I place in my C# code.    cbxGetInfo.Attributes.Add("onchecked", "javascript:if(confirm('Are you sure you want to delete this record?...

Java script cannot differentiate client side controls in user control used multiple on same webform
I have a textbox with a automcomplete extender and a client side link that, when clicked, changes style.display from "none" to "" to display a div that contains a listview with all possible choices for the text box.  I am using javascript to change the div style.display when the link is clicked.  When I have two instances of the usercontrol on the same webform, both links display the div on the first control.  How can the client side javascript tell the difference between the two divs? Try putting the javascript of the user c...

checkbox client side onclick event to manage checked status of multiple checkbox controls or multiple items in a checkboxlist
I want to use javascript to run a client side function to manage the checked state of multiple checkbox controls.  For example, if checkboxA is checked by the user, I want to uncheck checkboxB & checkboxC and check checkboxD.  I do not want to make this a postback event. Also, I'm considering using a checkboxlist control.  If I were to use a checkboxlist control with 6 list items, how would I control the checked status of the different list items based upon an onclick event for one of the list items.  An example: if checkbox list item (1) is checked, I want to unc...

How to access dynamically Html controls (client side controls) using C# server side scripts
Folks,I have problem try to to access dynamically Html controls (client side controls) using C# server side scripts. Please give me helps.     The error is as follows Exception Details: System.InvalidCastException: Specified cast is not valid.Source Error: Line 79: { Line 80: Control c = Page.FindControl("ddlTC" + i); Line 81: ((DropDownList)c).DataSource = mdt; Line 82: ((DropDownList)c).DataTextField = "ClassID"; Line 83: ((DropDownList)c).DataValueField = "Course"; My aspx page source codes: ...<...

Loaing Image to an Image COntrol using client side java script
SIr How can I Load an Image to an Image Control using JavaScript Expecting reply C T Ranjith Hi ctranjith, Try the following snipplet and then call it wherever you need it: function LoagImage() { document.getElementById('imgControl1').src = document.getElementById('btnExplore').value; } Hope it helps.MIGUELÓN.-----------------------------------------Rezad a vuestros dioses, amad a vuestras mujeres y luchad por vuestra patria! ----------------------------------------...

how to check if a checkbox is checked using javascript.
Hi all, I am new to asp.net and trying to learn it, I have created a simple page including a button and a checkboxes.  Now, I want that when I check the checkbox, it should display a message. but it is gving some errors like 1. ) expected 2. Invalid expresson term ':' 3. ; expexcted  4. Invalid expresson term ':'  my sample coding is as follows   <%@ Page Language="C#" AutoEventWireup="true" CodeFile="test.aspx.cs" Inherits="test" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Trans...

Check All Check Box While Check Header CheckBox
 hello...I have two grid on same page...both grid contains header checkbox and item checkbox i want that if use check header checkbox then all item check box checked,i have javascript for this functinality but problem is that when i click on header check box of first grid then checkbox of second grid also checked that i dnt want i want to perform this operation on one grid at one time.i have attache my script also...plz help me....thanks<script type="text/javascript">        function SelectAll(ID)      &nbs...

Check One CheckBox To Check All CheckBoxes
All the rows in a DataGrid, including the Header, are accompanied with a CheckBox. I want that when the CheckBox in the Header is checked, then all the CheckBoxes should automatically get checked. I set the AutoPostBack property of the CheckBox in the Header to True & am invoking a sub named CheckAllRows on the CheckedChanged event of this CheckBox. The CheckBox in the Header exists within the HeaderTemplate of a TemplateColumn in the DataGrid & the rest of the CheckBoxes reside within the ItemTemplate of the same TemplateColumn. This is the code (the ID of the CheckBox in the Header...

communication between client side(java script) and server side in .net project
I have a question which is, when building a .net project, we are able to use server side code and client side code(java script). How do they communicate? Thanks Client Side coding works with the WebBrowser. So when ever you write client side code you have to keep browser compatability in your mind and you have to code. Server Side code works with Web Server (IIS) and it's ASPNET ISAPI's. The won't directly communicate with each other. But using AJAX you can all server side code from Client Side! Example article on Ajax@ http://www.devarticles.com/index2.php?option=content&task=...

How to use client-side script(javascript) in DNA using .Net Remoting
Hi all,     It was known that SAO and Singleton object about .Net Remoting. When I Create an object in server side and hosting in IIS's virtual directory,I want to use javascript asynchronous invoking the remote object by HTTP channel, 80 port and SOAP formatter just like XMLHTTP invoking web service. My code as following, <script> objXmlDoc = new ActiveXObject("Msxml2.DOMDocument"); objHttp = new ActiveXObject("Msxml2.XMLHTTP"); strEnvelope = ?? objHttp.onreadystatechange = function() { ...... }   szUrl = "http://ServerNa...

Checkbox checked at client side???
Hi, I have a datagrid. In this datagrid At each row I have a checkbox to select the whole row. The second column is a bound column and it keeps the id of the product, the third contains the name of the product and so on... I want to get the id of the product as soon as i check the checkbox. However,this should be handled in client side. Can anyone help me? Thanks... Implement the ItemDataBound event of the grid and make sure ID of the row gets passed to the client side onclick event handler of the checkbox.Bug [MCSD] I'm sorry but I could not manage to implement ItemDataB...

How to check for the existing user in database and using custom validator how to check check box is checked or not?
Hi Friends, For Registration page i want to check if that user already exist in database or not? and i also have to check if user have check the checkbox for i agree then only he will be able to complete registration. here i am sending my design. and all validation i have done all validation except these two.<html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>PRIZE MLS</title><link href="css/style.c...

Web resources about - Not able to un-check or check my checkbox control using Java Script with .aspx - asp.net.client-side

UN nuclear inspectors check Iran's Arak plant
Atomic experts from the United Nations nuclear watchdog were at Iran’s Arak heavy water plant on Sunday to inspect it for the first time in more ...

Fact check: Does Australia spend more on offshore processing than the UN spends on refugee programs in ...
Human rights advocates say Australia's offshore processing spending is five times the UNHCR budget for South East Asia. ABC Fact Check investigates. ...

Jon Stewart on background-check deal & GOP freak out over UN arms treaties
Stewart noted how messed up it is that you can currently buy guns online without a background check. .

UN Monitors Due in Syria to Check Adherence to Cease-Fire
CTV.ca UN Monitors Due in Syria to Check Adherence to Cease-Fire BusinessWeek By Nayla Razzouk on April 16, 2012 United Nations military observers ...

Ebola checks stepped up as UN appeal ignored
Washington - Western countries scrambled to put airport security measures in place Friday amid mounting fear of the spread of Ebola worldwide. ...

UN mulls anti-IS moves as EU eyes tighter border checks post-Paris attacks
The UN was to vote Friday on a resolution boosting countries' powers to fight the Islamic State group behind the worst terror attacks on French ...

26/11 mastermind released: Modi govt gets reality check as China blocks UN action against Pakistan
... himself up against the Great Wall that China has become, not only for India but also for several other nations such as Japan and the United ...

FACT CHECK: Obama's UN Speech Spins Statistics
ABC News FACT CHECK: Obama's UN Speech Spins Statistics ABC News President Barack Obama glossed over some inconvenient truths Tuesday in his ...

Pilots must have regular medical check-ups: UN agency
Pilots must have regular mental and physical check-ups, the UN world aviation body said Thursday, after it emerged that a Germanwings first officer ...

Check Out This Hot Banger From Kim Jong Un's Girl Band, 'My Country Is the Best!'
Can you think of anything more fun than absolutely shredding a fiery guitar solo in honor of your Supreme Leader? Read more...

Resources last updated: 1/11/2016 7:49:31 AM