Click here to Skip to main content
15,903,362 members
Home / Discussions / C#
   

C#

 
GeneralRe: C#.Net application Pin
Colin Angus Mackay27-May-06 10:24
Colin Angus Mackay27-May-06 10:24 
GeneralRe: C#.Net application Pin
betty_boop27-May-06 10:36
betty_boop27-May-06 10:36 
GeneralRe: C#.Net application Pin
Ravi Bhavnani27-May-06 10:42
professionalRavi Bhavnani27-May-06 10:42 
GeneralRe: C#.Net application Pin
Colin Angus Mackay27-May-06 10:46
Colin Angus Mackay27-May-06 10:46 
GeneralRe: C#.Net application Pin
betty_boop27-May-06 11:21
betty_boop27-May-06 11:21 
GeneralRe: C#.Net application Pin
Colin Angus Mackay27-May-06 13:41
Colin Angus Mackay27-May-06 13:41 
GeneralRe: C#.Net application Pin
betty_boop28-May-06 9:14
betty_boop28-May-06 9:14 
Questionget whether a checkbox is checked or not ASP.net Pin
DeepToot27-May-06 7:36
DeepToot27-May-06 7:36 
Ok, this seems basic I know but for some reason it's giving me troubles. I have a checkbox on an asp.net page that gets checked...however, there is no postback going to happen on a button click. My question is how can I get the value of the checkbox without a postback?

I created an event and wired it to my continue button, once fired it does the validation. The client didnt like the fact that the page posted back when the checkbox was clicked (I was saving what was checked on postback). So I created this event.

I am able to get the control and everything, but it's telling me the Checked if false, when I know I checked it.

Here is the code I use to Iterate through the controls to find the checkbox:

Public Function IterateControls(ByVal parent As Control) As String<br />
        Dim id As String = ""<br />
        For Each child As Control In parent.Controls<br />
            If child.GetType().ToString().Equals("System.Web.UI.WebControls.CheckBox") Then<br />
                Dim clientid As Integer = child.ClientID.IndexOf("chk")<br />
                Dim cid As String = child.ClientID<br />
                Dim chk As CheckBox = CType(child, CheckBox)<br />
                    '**************************************<br />
                    'THIS RETURNS FALSE EVEN IF CHECKED<br />
                    '**************************************  <br />
                    If chk.Checked = True Then<br />
                    'get id of this control<br />
                    If id = "" Then<br />
                        id = chk.ID<br />
                    Else<br />
                        'already populated<br />
                        'they checked one too many<br />
                        'now warn them<br />
                        Dim lblwarn As Label = CType(Page.FindControl("lblWarning"), Label)<br />
                        lblwarn.Text = "You can only select ONE (1) Asset at a time!"<br />
                        lblwarn.ForeColor = Color.Red<br />
                        chk.Checked = False<br />
                        Return "-1"<br />
                    End If<br />
<br />
                End If<br />
            End If<br />
            If child.HasControls Then<br />
                IterateControls(child)<br />
            End If<br />
        Next<br />
        Return id<br />
    End Function


Anyone have any clue if I am able to capture a value even though there is no postback happening?

VB or C# examples would be appreciated. Thanks

Steve Welborn
Software Engineer
BitWise Solutions
AnswerRe: get whether a checkbox is checked or not ASP.net Pin
maryamf27-May-06 11:33
maryamf27-May-06 11:33 
GeneralRe: get whether a checkbox is checked or not ASP.net Pin
DeepToot27-May-06 12:59
DeepToot27-May-06 12:59 
GeneralRe: get whether a checkbox is checked or not ASP.net Pin
leppie27-May-06 18:32
leppie27-May-06 18:32 
GeneralRe: get whether a checkbox is checked or not ASP.net Pin
DeepToot28-May-06 15:41
DeepToot28-May-06 15:41 
Questiontextbox cursor disable Pin
jackalfb27-May-06 6:20
jackalfb27-May-06 6:20 
AnswerRe: textbox cursor disable Pin
Guffa27-May-06 6:49
Guffa27-May-06 6:49 
GeneralRe: textbox cursor disable Pin
jackalfb27-May-06 9:27
jackalfb27-May-06 9:27 
AnswerRe: textbox cursor disable Pin
Guffa27-May-06 22:50
Guffa27-May-06 22:50 
QuestionDBNull and Uniqe ID Pin
NaNg1524127-May-06 5:42
NaNg1524127-May-06 5:42 
Questionusing the scalar execute mode in ado.net 2.0. help!!! Pin
aenon27-May-06 5:41
aenon27-May-06 5:41 
QuestionRegular Expression Control Pin
NaNg1524127-May-06 4:56
NaNg1524127-May-06 4:56 
AnswerRe: Regular Expression Control Pin
Guffa27-May-06 5:14
Guffa27-May-06 5:14 
QuestionRe: Regular Expression Control Pin
NaNg1524127-May-06 5:35
NaNg1524127-May-06 5:35 
GeneralRe: Regular Expression Control Pin
Guffa27-May-06 7:16
Guffa27-May-06 7:16 
GeneralRe: Regular Expression Control Pin
NaNg1524127-May-06 7:28
NaNg1524127-May-06 7:28 
AnswerRe: Regular Expression Control Pin
Guffa27-May-06 8:35
Guffa27-May-06 8:35 
AnswerRe: Regular Expression Control Pin
Al Ortega27-May-06 6:12
Al Ortega27-May-06 6:12 

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.