Click here to Skip to main content
15,895,667 members
Home / Discussions / Web Development
   

Web Development

 
GeneralRe: include files and event handling Pin
Jesse Evans23-Mar-06 9:27
Jesse Evans23-Mar-06 9:27 
GeneralRe: include files and event handling Pin
gagirl_4323-Mar-06 13:55
gagirl_4323-Mar-06 13:55 
GeneralRe: include files and event handling Pin
Jesse Evans24-Mar-06 6:03
Jesse Evans24-Mar-06 6:03 
Questionhow to send and receive sms from internet Pin
govindnaroji25-Mar-05 7:23
govindnaroji25-Mar-05 7:23 
Questionasp:button image? Pin
bizjosh25-Mar-05 0:19
bizjosh25-Mar-05 0:19 
General[ASP.net / C#] Checkbox Checked Always false Pin
Jaymz66624-Mar-05 23:57
Jaymz66624-Mar-05 23:57 
GeneralRe: [ASP.net / C#] Checkbox Checked Always false Pin
Jeff Martin28-Mar-05 7:38
Jeff Martin28-Mar-05 7:38 
GeneralRe: [ASP.net / C#] Checkbox Checked Always false Pin
Jaymz66628-Mar-05 21:41
Jaymz66628-Mar-05 21:41 
Here is my code:

private void Page_Load(object sender, System.EventArgs e)<br />
{<br />
   // This Array is used as temp. replacement for a database<br />
   strApp[0] = "Word";<br />
   strApp[1] = "Excel";<br />
   strApp[2] = "Calculator";<br />
   strApp[3] = "Solitaire";<br />
   strApp[4] = "Explorer";<br />
<br />
   fillTable();  //GoTo fillTable function<br />
<br />
   if (IsPostBack)<br />
   {<br />
       showCheckbox();<br />
   }<br />
}


I also tried to put the FillTable() behind the !IsPostback but then he can't find any checkboxes at all. So I need to 'Fill the table' every postback.

The code to fill the table:

public void fillTable()<br />
{<br />
   int numberOfApps = strApp.Length;<br />
 <br />
   for(int i=0 ; i < numberOfApps ; i++)<br />
   {       <br />
     TableRow tr = new TableRow();<br />
     TableCell tc_box = new TableCell();<br />
     TableCell tc_app = new TableCell();        <br />
     <br />
     CheckBox chkBox = new CheckBox();<br />
     chkBox.ID   = "chk" + i.ToString();<br />
     chkBox.Text = "#"+i.ToString();<br />
     chkBox.AutoPostBack=true;<br />
     chkBox.EnableViewState=true;  // I thought this might work<br />
<br />
     tc_box.Controls.Add(chkBox);<br />
     tc_app.Text =strApp[i];<br />
     tr.Cells.Add(tc_box);<br />
     tr.Cells.Add(tc_app);<br />
     Table1.Rows.Add(tr);<br />
   }<br />
}


Works nice Smile | :) . In this case (just for debuggin' sake) I've enabled AutoPostBack. So when I select one checkbox he postsback the page wich wil fire up the showCheckbox() function:

public void showCheckbox()<br />
{<br />
   for (int i = 0 ; i < strApp.Length ; i++)<br />
   {<br />
    CheckBox c;  <br />
    <br />
    c = (CheckBox)FindControl("chk"+i.ToString());<br />
<br />
    if (c.Checked==true)<br />
    {<br />
      // The checkbox is FALSE<br />
      Response.Write(c.ID);<br />
      Response.Write("Works!");<br />
    }<br />
    else<br />
    {<br />
      // The checkbox is FALSE<br />
    }<br />
  }<br />
}


As you can see I loop through the checkboxes with id's like: chk0, chk1 etc. He finds them! While debugging I can retrieve the checkboxes ID's! But the checked-state is false while he still is checked (true) in the InternetExplorer window.

I think it's got something to do with the postback & refilling the table. As showed above the page puts, everytime the page reloads, new checkboxes in the table. Where he doesn't check wheter the previous boxes are checked or not. Should I use something like a Session-array to store the checkboxes in? If yes, how do I do that?

Greetingz,
Eric
GeneralRe: [ASP.net / C#] Checkbox Checked Always false Pin
Jeff Martin29-Mar-05 3:13
Jeff Martin29-Mar-05 3:13 
GeneralJavascript for adding html Pin
shaiba24-Mar-05 19:12
shaiba24-Mar-05 19:12 
GeneralRe: Javascript for adding html Pin
Yulianto.27-Mar-05 15:37
Yulianto.27-Mar-05 15:37 
GeneralRe: Javascript for adding html Pin
Anonymous27-Mar-05 17:33
Anonymous27-Mar-05 17:33 
GeneralRe: Javascript for adding html Pin
Yulianto.27-Mar-05 17:47
Yulianto.27-Mar-05 17:47 
GeneralASP.NET VB on DWMX for User Registration page Pin
bizjosh24-Mar-05 17:36
bizjosh24-Mar-05 17:36 
GeneralCSocket &amp; critical sections under IIS 6 Pin
Sorin24-Mar-05 15:48
Sorin24-Mar-05 15:48 
GeneralASP cant read the data from the Access database Pin
Member 145397924-Mar-05 15:39
Member 145397924-Mar-05 15:39 
GeneralRe: ASP cant read the data from the Access database Pin
Hesham Amin26-Mar-05 0:53
Hesham Amin26-Mar-05 0:53 
GeneralProblems Transfering div contents x-browser Pin
loane24-Mar-05 12:40
loane24-Mar-05 12:40 
GeneralQuestion regarding using the same input! Pin
Jamal42024-Mar-05 10:42
Jamal42024-Mar-05 10:42 
Generalcombo control appear infront of menu Pin
TariqMahmood24-Mar-05 0:41
TariqMahmood24-Mar-05 0:41 
GeneralCWebBrowser ActiveX Pin
Grahamfff23-Mar-05 10:46
Grahamfff23-Mar-05 10:46 
GeneralDestroying objects Pin
paixtis23-Mar-05 9:00
paixtis23-Mar-05 9:00 
GeneralA string problem.. Pin
Monisankar22-Mar-05 22:53
Monisankar22-Mar-05 22:53 
GeneralRe: A string problem.. Pin
Jeff Martin23-Mar-05 8:20
Jeff Martin23-Mar-05 8:20 
GeneralRe: A string problem.. Pin
kutz923-Mar-05 10:54
kutz923-Mar-05 10:54 

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.