473,372 Members | 1,125 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,372 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 8165
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: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.