09-21-2005, 01:41 PM
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
09-21-2005, 03:40 PM
There shouldn't be an error. The result should overwrite the value in textbox2.
Post some code.
09-21-2005, 03:46 PM
see http://www.a webforyou.com/dtstranslatetext2.aspx
it might only happen if you select a different language to translate to.
09-21-2005, 04:17 PM
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.
09-21-2005, 04:30 PM
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
09-21-2005, 06:44 PM
Are you using VS.NET?
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".
09-22-2005, 06:19 AM
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?
09-22-2005, 02:50 PM
A quick search of macromedia forums yielded this. Give it a shot. (add the compilation tag to web config)
Web Config settings.
09-22-2005, 05:25 PM
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?
09-22-2005, 05:39 PM
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?
in your button click...
TextBox2.Text = ""
then do your call..
09-22-2005, 05:44 PM
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.
09-22-2005, 05:49 PM
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.
[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.UI.Page.ProcessRequest(HttpContext context) +18
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +87
09-22-2005, 07:08 PM
See how much useful that is?
Now you know the problem.
Nothing to do with the textbox having a value.
It doesn't like
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. (http://www.asp.net/faq/RequestValidation.aspx)
09-23-2005, 06:41 AM
hi! i'm confused -- what is the problem?
09-23-2005, 02:49 PM
Did you read the linked article?
It explains it better than I could. :D
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.
09-23-2005, 02:56 PM
but the error only happens when they are in the second textbox not the first ---
so wouldnt' it help if I clear it?
what else can i do?
09-23-2005, 07:19 PM
What else can you do?
READ THE ARTICLE I LINKED BECAUSE IT TELLS YOU WHAT TO DO.
Here it is again.
09-25-2005, 07:09 AM
thanks -- your right :)
I appreciate your help -- that solved it!