Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 3rd, 2007, 01:58 PM
Authorized User
 
Join Date: Sep 2006
Posts: 82
Thanks: 0
Thanked 0 Times in 0 Posts
Default Reset Button Query

Hi,

I have a submission form that I have designed and within the form there is a reset button that clears all of the fields. Basically I used the logic when you click on the button it clears each textbox's entry using quotation marks. I tested this ideas successfully within a simple form. However when applied to my form this does not clear the text boxes. The form uses required validators and regular expressions

Any ideas ? The code is asp.net 1.1 using vb.net :

Code:
 Sub Reset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        If Page.IsPostBack Then

        txtName.Text = " "
        txtHouse.Text = " "
        txtStreet.Text = " " etc....
              End If
    End Sub

 Form code....

 

<table class="cellfillalt" height="150" cellspacing="0" cellpadding="6" width="420" align="center" border="1">
                <tbody>
                    <tr>
                        <td width="110">
                            <p align="right">
                                <asp:Label id="lblTitle" runat="server" cssclass="mandatory">Title:</asp:Label>
                            </p>
                        </td>
                        <td width="200">
                            <p align="center">
                                <asp:TextBox id="txtTitle" runat="server" CssClass="txtbox"></asp:TextBox>
                            </p>
                        </td>
                        <td width="110">
                            <asp:RequiredFieldValidator id="RFTitleValidator" runat="server" CssClass="formerror" ControlToValidate="txtTitle" ErrorMessage="Enter your title e.g. Mr, Mrs." ForeColor=" "></asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <p align="right">
                                <asp:Label id="lblName" runat="server" cssclass="mandatory">Full Name:</asp:Label>
                            </p>
                        </td>
                        <td width="200">
                            <p align="center">
                                <asp:TextBox id="txtName" runat="server" CssClass="txtbox"></asp:TextBox>
                            </p>
                        </td>

 
Old April 3rd, 2007, 02:11 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Do you manually wire up the click event with Addhandler? If not you need to add: Handles btnReset.Click after your method signature.

Also, I see a possible bug in your code. You arent really clearing your textboxes, you are replacing the values with a non breaking space (whitespace) which may cause your validators to not fire since there is actually data present in the textbox, albeit just white space.

hth.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========
 
Old April 3rd, 2007, 02:22 PM
Authorized User
 
Join Date: Sep 2006
Posts: 82
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks,

There is an event handler set. With regards your second point, what are the other alternatives for clearing the dields on the form, thanks ?

 
Old April 3rd, 2007, 02:52 PM
Authorized User
 
Join Date: Sep 2006
Posts: 82
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Fixed it now - thanks






Similar Threads
Thread Thread Starter Forum Replies Last Post
Button Query rsm42 ASP.NET 1.0 and 1.1 Basics 5 August 1st, 2007 10:19 AM
Button / Form Query rsm42 ASP.NET 1.0 and 1.1 Basics 2 June 5th, 2007 11:52 AM
Reset Button in VB.net 2005 asta2007 Visual Studio 2005 1 May 29th, 2007 12:13 AM
Assigning Command Button to Query young20 Access VBA 1 November 6th, 2006 12:15 PM
BackgroundImage reset ryan.thomson VB.NET 2002/2003 Basics 0 October 25th, 2005 08:39 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.