473,396 Members | 1,929 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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 8170
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Sylvian Stone | last post by:
Hi there - I'm experiencing a very frustrating problem with an application that submits POST info to a session control file which then echo's it back to the controls if the page is returned to. ...
2
by: John E | last post by:
How do I get whether a checkbox is ticked in a form on a form's submission (true or false)? How do I use the Request object in ASP?
6
by: Shabam | last post by:
I have a text field that's pre-filled with data. Suppose the user edits it, but decides he wants to reset the data back to the original pre-filled data, how can I do that?
6
by: effendi | last post by:
I have a page with checkboxes generated by a script. Users are suppose to select the checkboxes and click on a button to process their selection. The codes work fine except when I only have one...
1
by: Rob Meade | last post by:
Lo all, Just after some suggestions here really... I have a page which lists a members of staff who have left our organisation, this list is then used by various departments in our...
34
by: clinttoris | last post by:
Hello Experts, I have been told to post this in the Javascript forum as I want to do this client side just before my form gets submitted. Once the user clicks the submit button a javascript...
3
by: kashif_khan | last post by:
hi everyone, can anybody please tell me why reset button is not working in the following code, i tested it in opera, firefox and konqueror, <form action='edit_links.php' method='POST'...
1
by: shobana | last post by:
Hi I have a bunch of checkboxes. While in fetch method iam checking it and disabling the checkbox which has data in backend. Rest are enabled. User can check the rest and update it. While in form...
1
by: theresa | last post by:
I'm about at my wits end trying to figure out why this isn't working, so I'm hoping one of you can help! I'm sure there must be something simple I'm missing. I have a checkbox on an Asp.NET 2.0...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.