Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 18

Thread: clear textbox

  1. #1
    Senior Coder
    Join Date
    May 2004
    Posts
    1,441
    Thanks
    15
    Thanked 0 Times in 0 Posts

    clear textbox

    I have a form that when the submit button is pressed it calls a object through soap and returns a value to the textbox2.
    The problem is that if immediately the user puts something else in textbox one and submits again then there is an error.

    How can I clear textbox 2 before it is executed to avoid the error.
    If anyone can help me I would appreciate it. I'm very new to .net

  • #2
    Senior Coder nikkiH's Avatar
    Join Date
    Jun 2005
    Location
    Near Chicago, IL, USA
    Posts
    1,973
    Thanks
    1
    Thanked 32 Times in 31 Posts
    There shouldn't be an error. The result should overwrite the value in textbox2.
    Post some code.

    If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
    Bored? Visit
    http://www.kaelisspace.com/

  • #3
    Senior Coder
    Join Date
    May 2004
    Posts
    1,441
    Thanks
    15
    Thanked 0 Times in 0 Posts
    see http://www.a webforyou.com/dtstranslatetext2.aspx

    it might only happen if you select a different language to translate to.

  • #4
    Senior Coder nikkiH's Avatar
    Join Date
    Jun 2005
    Location
    Near Chicago, IL, USA
    Posts
    1,973
    Thanks
    1
    Thanked 32 Times in 31 Posts
    Post SERVER-SIDE code.
    Seeing the client-side code doesn't help a lot.

    And compile in debug mode (not release mode) so you get a useful error message.

    If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
    Bored? Visit
    http://www.kaelisspace.com/

  • #5
    Senior Coder
    Join Date
    May 2004
    Posts
    1,441
    Thanks
    15
    Thanked 0 Times in 0 Posts
    how do I compile in debug mode?
    (I am very new to .net and usually use asp)

    the code pulls up from a soap object.

    I think this is where it is done...

    Private Sub TranslateButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TranslateButton.Click
    Dim result As String = myService.translateTextBasic(SourceTextBox.Text, DirectionsDropDownList.SelectedValue)
    TargetTextBox.Text = result

    End Sub

  • #6
    Senior Coder nikkiH's Avatar
    Join Date
    Jun 2005
    Location
    Near Chicago, IL, USA
    Posts
    1,973
    Thanks
    1
    Thanked 32 Times in 31 Posts
    Are you using VS.NET?
    Build->Configuration Manager
    Select DEBUG in the menu, click OK.
    (mine was already there; let me know if yours isn't and I will find out how to add it)
    Then build the project, which builds and compiles.
    You will get complete error messages, including line numbers and the code that threw the exception.

    TargetTextBox.Text = result

    Where is that variable TargetTextBox defined? Is that the name you gave the textbox?
    Note that I use C#, not VB. So bear with me if this is something VB "knows".

    If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
    Bored? Visit
    http://www.kaelisspace.com/

  • #7
    Senior Coder
    Join Date
    May 2004
    Posts
    1,441
    Thanks
    15
    Thanked 0 Times in 0 Posts
    I am using dreamweaver.
    I usually program in just asp but needed .net and used this based on someone elses example.

    Is there anything I can do?

  • #8
    Senior Coder nikkiH's Avatar
    Join Date
    Jun 2005
    Location
    Near Chicago, IL, USA
    Posts
    1,973
    Thanks
    1
    Thanked 32 Times in 31 Posts
    A quick search of macromedia forums yielded this. Give it a shot. (add the compilation tag to web config)

    --------------------------
    Web Config settings.

    <configuration>
    <system.web>
    <customErrors mode="Off"/>
    <pages smartNavigation="true"/>
    <compilation debug="true"/>

    If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
    Bored? Visit
    http://www.kaelisspace.com/

  • #9
    Senior Coder
    Join Date
    May 2004
    Posts
    1,441
    Thanks
    15
    Thanked 0 Times in 0 Posts
    now it gives an error??

    don't think that was right.
    do you have any idea what i can try doing to clear the textbox as the code begins again?
    if i manually refresth then it works fine -- can i force a refresh on click before the code goes?

  • #10
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    I'm kindof confused, but have you tried setting the textbox to an empty string when you click the button, and then do your call?

    Code:
    in your button click...
    TextBox2.Text = ""
    then do your call..

  • #11
    Senior Coder nikkiH's Avatar
    Join Date
    Jun 2005
    Location
    Near Chicago, IL, USA
    Posts
    1,973
    Thanks
    1
    Thanked 32 Times in 31 Posts
    I think you put it outside the element it needed to be in, since I don't see it on the error page.

    Learn to do this the right way. Don't hack it by setting the control to empty first. You'll be happier later. You might run into the same problem that was actually a result of bad code you did somewhere or some other gotcha. You will eventually want decent error messages.

    If you need results right now due to a deadline, you can set the value of the textbox to be empty by using
    Me.Textbox1.Text = String.Empty
    in Page_Load, but be sure to be careful it runs before your SOAP code. But as I said, I really don't recommend this sort of thing -- it can mask real issues.

    If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
    Bored? Visit
    http://www.kaelisspace.com/

  • #12
    Senior Coder
    Join Date
    May 2004
    Posts
    1,441
    Thanks
    15
    Thanked 0 Times in 0 Posts
    nope

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Stack Trace:


    [HttpRequestValidationException (0x80004005): A potentially dangerous Request.Form value was detected from the client (TargetTextBox="...s ist ein <A[Test|Prüfung]>").]
    System.Web.HttpRequest.ValidateString(String s, String valueName, String collectionName) +240
    System.Web.HttpRequest.ValidateNameValueCollection(NameValueCollection nvc, String collectionName) +99
    System.Web.HttpRequest.get_Form() +121
    System.Web.UI.Page.GetCollectionBasedOnMethod() +70
    System.Web.UI.Page.DeterminePostBackMode() +128
    System.Web.UI.Page.ProcessRequestMain() +2112
    System.Web.UI.Page.ProcessRequest() +218
    System.Web.UI.Page.ProcessRequest(HttpContext context) +18
    System.Web.CallHandlerExecutionStep.System.Web.HttpApplication+IExecutionStep.Execute() +179
    System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +87

  • #13
    Senior Coder nikkiH's Avatar
    Join Date
    Jun 2005
    Location
    Near Chicago, IL, USA
    Posts
    1,973
    Thanks
    1
    Thanked 32 Times in 31 Posts
    See how much useful that is?
    Now you know the problem.
    Nothing to do with the textbox having a value.
    It doesn't like
    <U[there]>
    in the textbox because of the <>, which can be used for script injection attacks.

    Here's an article from MSDN about how to handle this.

    If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
    Bored? Visit
    http://www.kaelisspace.com/

  • #14
    Senior Coder
    Join Date
    May 2004
    Posts
    1,441
    Thanks
    15
    Thanked 0 Times in 0 Posts
    hi! i'm confused -- what is the problem?

  • #15
    Senior Coder nikkiH's Avatar
    Join Date
    Jun 2005
    Location
    Near Chicago, IL, USA
    Posts
    1,973
    Thanks
    1
    Thanked 32 Times in 31 Posts
    Did you read the linked article?
    It explains it better than I could.

    But, in my own words, the problem is that the characters '<' and '>' are used by the Bad People (tm) to hurt your stuff, so .net disallows them by default in form submissions.

    If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
    Bored? Visit
    http://www.kaelisspace.com/


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •