469,645 Members | 1,150 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,645 developers. It's quick & easy.

Reset checkbox after form submission

I have a form which includes a checkbox field. I need to add a reset, I
add a HTML reset it works fine before I submit the form but not after. I
know I must add some code to reset the checkbox on the onclick event of
the reset button but I don't know what the code should be. Below is the
HTML for the Data grid that has the check box and the code from the C#
behind code for the reset button. If someone could point me in the right
direction I would be very grateful.

HTML

<form id="Form1" method="post" runat="server">
<asp:datagrid id="DemoGrid" style="Z-INDEX: 104; LEFT: 8px; POSITION:
absolute; TOP: 200px" runat="server" Font-Size="XX-Small"
DataKeyField="customer">
<Columns>
<asp:TemplateColumn HeaderText="Run">
<ItemTemplate>
<asp:CheckBox ID="myCheckbox" Runat="server" />
</ItemTemplate>
</asp:TemplateColumn>

</Columns>
</asp:datagrid>
<input type='reset' value='Reset' style="Z-INDEX: 105; LEFT: 168px;
POSITION: absolute; TOP: 80px" id="Reset1" name="Reset1" runat="server">
</form>

#C Code

private void Reset1_ServerClick(object sender, System.EventArgs e)
{

foreach(DataGridItem DemoGridItem in DemoGrid.Items)
{
CheckBox myCheckbox = (CheckBox)DemoGridItem.Cells[0].Controls[1];
myCheckbox.Checked = false;
}

}
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #1
1 7734
Hi Joe,

The Reset1_ServerClick method should be declared as protected or public, not
private
You also need to change the button declaration, like this:

<asp:Button style="Z-INDEX: 105; LEFT: 168px; POSITION: absolute; TOP:
80px"
ID="Reset1" name="Reset1" runat="server" onClick="Reset1_ServerClick"
</asp:Button>

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Joe Bloggs" <bo********@netscape.net> wrote in message
news:OJ*************@TK2MSFTNGP11.phx.gbl... I have a form which includes a checkbox field. I need to add a reset, I
add a HTML reset it works fine before I submit the form but not after. I
know I must add some code to reset the checkbox on the onclick event of
the reset button but I don't know what the code should be. Below is the
HTML for the Data grid that has the check box and the code from the C#
behind code for the reset button. If someone could point me in the right
direction I would be very grateful.

HTML

<form id="Form1" method="post" runat="server">
<asp:datagrid id="DemoGrid" style="Z-INDEX: 104; LEFT: 8px; POSITION:
absolute; TOP: 200px" runat="server" Font-Size="XX-Small"
DataKeyField="customer">
<Columns>
<asp:TemplateColumn HeaderText="Run">
<ItemTemplate>
<asp:CheckBox ID="myCheckbox" Runat="server" />
</ItemTemplate>
</asp:TemplateColumn>

</Columns>
</asp:datagrid>
<input type='reset' value='Reset' style="Z-INDEX: 105; LEFT: 168px;
POSITION: absolute; TOP: 80px" id="Reset1" name="Reset1" runat="server">
</form>

#C Code

private void Reset1_ServerClick(object sender, System.EventArgs e)
{

foreach(DataGridItem DemoGridItem in DemoGrid.Items)
{
CheckBox myCheckbox = (CheckBox)DemoGridItem.Cells[0].Controls[1];
myCheckbox.Checked = false;
}

}
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 16 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Sylvian Stone | last post: by
6 posts views Thread by Shabam | last post: by
1 post views Thread by Rob Meade | last post: by
34 posts views Thread by clinttoris | last post: by
3 posts views Thread by kashif_khan | last post: by
1 post views Thread by theresa | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.