Click here to Skip to main content
16,016,882 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: ImageUrl does not update in Updatepanel Pin
Clay Aldebol24-Feb-09 14:51
Clay Aldebol24-Feb-09 14:51 
AnswerRe: ImageUrl does not update in Updatepanel Pin
Clay Aldebol28-Feb-09 6:12
Clay Aldebol28-Feb-09 6:12 
Question[Message Deleted] Pin
Terick24-Feb-09 11:14
Terick24-Feb-09 11:14 
AnswerRe: Javascript to disable button on form if checkbox in gridview is selected Pin
Christian Graus24-Feb-09 12:27
protectorChristian Graus24-Feb-09 12:27 
QuestionRepeater control Pin
cyxapebpek24-Feb-09 10:46
cyxapebpek24-Feb-09 10:46 
AnswerRe: Repeater control Pin
Christian Graus24-Feb-09 11:43
protectorChristian Graus24-Feb-09 11:43 
GeneralRe: Repeater control Pin
cyxapebpek24-Feb-09 11:47
cyxapebpek24-Feb-09 11:47 
QuestionJavascript to enable/disable textbox based on checkbox [modified] Pin
Terick24-Feb-09 10:27
Terick24-Feb-09 10:27 
Hi~

I have a user control with a gridvew that contains a checkbox and textbox. The textbox is set to Enabled=false by default.

On Page 1: the Header of the checkbox column is "Remove" and there is a Save button. On this page I need all UNCHECKED rows to have an enabled textbox

On Page 2: the Header of the checkbox column is "Select". On this page I need all CHECKED rows to have an enabled textbox and all others to be disabled.

How do I create the javascript for these requirements? I am using asp.Net and C#.

Here is my sample code:
UserControl.ascx:
<asp:gridview xmlns:asp="#unknown">

<asp:templatefield headertext="Select">
<itemtemplate>
<asp:checkbox id="chkBox" runat="server" checked="<%#Bind(" />
</itemtemplate>
</asp:templatefield>
<asp:templatefield headertext="Size">
<itemtemplate>
<asp:textbox id="txtSize" runat="server" text="<%#Bind(" size=")%>" readonly="false" enabled="false" enabledviewstate="true"> </asp:textbox>


</itemtemplate></asp:templatefield></asp:gridview>


Current JavaScript:
function CheckChanged(cb, tb)
{
var chkBox=document.getElementById(cb);
var txtSize=document.getElemetnById(tb);
if(chkBox.checked)
{
txtSize.disabled=true;
txtSize.style.backgroundColor=\"lightgray\";
}
else
{
txtSize.disabled= false;
}
}


This javascript is getting written via a StringBuilder in the .aspx.cs file of each page. Currently, I can only get the script to work properly for Page 2. On Page 1, I need the textbox to always be enabled unless something is checked. What is the best way to enable the textboxes on this page?

Thanks!

modified on Wednesday, February 25, 2009 9:39 AM

AnswerRe: Javascript to enable/disable textbox and button based on checkbox Pin
ToddHileHoffer24-Feb-09 10:42
ToddHileHoffer24-Feb-09 10:42 
GeneralRe: Javascript to enable/disable textbox and button based on checkbox Pin
Terick24-Feb-09 10:51
Terick24-Feb-09 10:51 
GeneralRe: Javascript to enable/disable textbox and button based on checkbox Pin
ToddHileHoffer24-Feb-09 12:54
ToddHileHoffer24-Feb-09 12:54 
GeneralRe: Javascript to enable/disable textbox and button based on checkbox Pin
Terick25-Feb-09 3:39
Terick25-Feb-09 3:39 
QuestionDataset vs Customcollection Pin
Mogaambo24-Feb-09 10:09
Mogaambo24-Feb-09 10:09 
AnswerRe: Dataset vs Customcollection Pin
ToddHileHoffer24-Feb-09 10:35
ToddHileHoffer24-Feb-09 10:35 
QuestionActivation Code... Pin
sitnet24-Feb-09 8:47
sitnet24-Feb-09 8:47 
AnswerRe: Activation Code... Pin
Christian Graus24-Feb-09 9:21
protectorChristian Graus24-Feb-09 9:21 
QuestionASP.net Pin
Suchinthaka24-Feb-09 6:19
Suchinthaka24-Feb-09 6:19 
AnswerRe: ASP.net Pin
varsha dixit24-Feb-09 7:04
varsha dixit24-Feb-09 7:04 
GeneralRe: ASP.net [modified] Pin
ToddHileHoffer24-Feb-09 8:28
ToddHileHoffer24-Feb-09 8:28 
GeneralRe: ASP.net Pin
Yusuf24-Feb-09 11:33
Yusuf24-Feb-09 11:33 
GeneralRe: ASP.net Pin
ToddHileHoffer24-Feb-09 12:59
ToddHileHoffer24-Feb-09 12:59 
AnswerRe: ASP.net Pin
Christian Graus24-Feb-09 8:28
protectorChristian Graus24-Feb-09 8:28 
QuestionMDB view thru browser Pin
Civic0624-Feb-09 5:55
Civic0624-Feb-09 5:55 
AnswerRe: MDB view thru browser Pin
Jon Rista24-Feb-09 6:17
Jon Rista24-Feb-09 6:17 
GeneralRe: MDB view thru browser Pin
Christian Graus24-Feb-09 8:29
protectorChristian Graus24-Feb-09 8:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.