Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
hi,
I am using special character in asp textbox. but when i do any operation with another control like buttons, then at client level
Sys.WebForms.WebequestManager problem raise.
 
what i should i do to allow special character in asp textbox?
 
i already tried ValidateRequest="false" attribute with Page directive but
problem still there.
Posted 7-Jan-13 19:56pm
amit_83964
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You're using ASP.NET, not ASP. There is no such thing as an asp or asp.net textbox. It's just a HTML input control. I think you're saying you get an issue with using characters that look like a script injection.
 
http://msdn.microsoft.com/en-us/library/ff647397.aspx[^] explains how to turn on validation. Reverse the advice to turn it off. If you've tried all that, try posting code of what you've done, and the actual error message.
  Permalink  
Comments
amit_83 at 8-Jan-13 2:27am
   
i have used fallowing string in textbox I noticed that the email from gmail are sent from the sender "codeproject Admin <abc-admin@cp.com>". Why "ABC-admin"? It should rather be "CPs-admin".
Christian Graus at 8-Jan-13 2:49am
   
What email ? What text ?
amit_83 at 8-Jan-13 3:47am
   
i have used whole text written below I noticed that the email from gmail are sent from the sender "codeproject Admin <abc-admin@cp.com>". Why "ABC-admin"? It should rather be "CPs-admin".
Christian Graus at 8-Jan-13 3:49am
   
I guess you just joined. The site sends you notifications. What makes you think I have control over what their format is ? Why do you care ?
amit_83 at 8-Jan-13 3:51am
   
My dear this is not an email sent from any where. It just an example text i shown to you. My question is if i use special charecter like <, >," sign then Sys.WebForms.WebequestManager problem raise problem raise. what can i do to resolve this issue?
Christian Graus at 8-Jan-13 3:56am
   
Oh - OK, that's very unclear. You do what I said. Go through that article, it shows all the places it should be turned on. Turn it off in all those places. Then, if you still have an error, show us the code and tell us the exact error message.
amit_83 at 8-Jan-13 4:04am
   
Thanks for reply. But it did not work.
Christian Graus at 8-Jan-13 4:06am
   
I don't know what to tell you. You're not being at all clear. You need to tell us what you did, and what 'it did not work' means. Because, somewhere your project is turning on this sort of validation. It's not happening by magic, and we can't say a spell to fix it. The info I linked to, is correct. You may look for an article that matches your version of .NET, but somehow, somewhere, you don't have this turned off, that's why it is doing what it is.
amit_83 at 8-Jan-13 4:38am
   
Thanks for reply, i will see once more. but what i did i have used <,>,"" character in my textbox, and i clicked on a button then Sys.WebForms.WebequestManager problem raise. i turned off ValidateRequest="false" as suggest in the article you suggest, but it give me the problem at client end. At client end Sys.WebForms.WebequestManager raise.
Zafar Sultan at 8-Jan-13 2:55am
   
Amit_83,why are you so very concerned about abc-admin or cps-admin? You don't own codeproject so whatever is the e-mail id they use(abc-admin, xyz-admin or thereisnoadmin) it has to do nothing with your problem. Why don't you stick to your problem rather that advicing what to use?
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

A neat solution without turning requestvalidation to "off" is to use javascript. Suppose your textbox is "TextBox1" and on button("Button1") click event you want to perform server side operation follow the steps:
1) Include this script in head of your document:
<script>
  function ReplaceCharacter() {
   var value = (document.getElementById('TextBox1').value);
   value = value.replace('<', '&lt ;');//no space between &lt and ;
   value = value.replace('>', '&gt ;');//no space between &gt and ;
   document.getElementById('TextBox1').value = value;
  }
 </script>
2) In code behind write:
Button1.Attributes.Add("onclick","ReplaceCharacter();");
3) Wherever you want to get the value of textbox in server side code write:
string myString = Server.HtmlDecode(TextBox1.Text);
  Permalink  
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Guruprasad.K.Basavaraju 400
1 Shai Vashdi 334
2 Sergey Alexandrovich Kryukov 305
3 OriginalGriff 265
4 Peter Leow 171
0 Sergey Alexandrovich Kryukov 8,979
1 OriginalGriff 5,280
2 Peter Leow 4,010
3 Maciej Los 3,535
4 Abhinav S 3,263


Advertise | Privacy | Mobile
Web01 | 2.8.140415.2 | Last Updated 8 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid