String comparison in VS2003

Posted by Sibin.rhythm under ASP.NET on 8/28/2009 | Views : 1194 | Status : [Member] | Replies : 4
public bool check_text(string txt)
{
if (Strings.InStr(txt, "'") > 0)
{
return false;
}
}

Actually I am using Visual studio 2003. So this code to compare strrings in the textbox did not work. If there is any other code to compare strings in visual studio 2003??

Can Anybody help me????




Responses

Posted by: Lakhangarg on: 8/29/2009 [Member] [Moderator] Silver

Up
0
Down
Hi sibin -

Can you please explain your problem clearly..
if you want to just check that if the string is empty return false then use like this:
if(txt=="")
return false;

if you have any other query the please explain it clearly means what is your input and what you want as a output..

Thanks & Regards
Lakhan Pal Garg
http://lakhangarg.blogspot.com



Sibin.rhythm, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sibin.rhythm on: 8/29/2009 [Member] Starter

Up
0
Down
Thank you for ur reply

I have one text box. If anybody enters value like <,>,create,drop etc,The error message will come.

I need To avoid that.Also My Visual studio software does not support Valiation controls like regular expression validtor,required field validatr etc,So I cant use regular expression validatior to avoid this sql injection

B'coz of this reason I decide to use string comparison to check the textbox value charrecter by charrecter . so I can find out the illegal symbols which entered in the text box.

Then I can display the error message...

Can u help me???

Sibin.rhythm, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Lakhangarg on: 8/29/2009 [Member] [Moderator] Silver

Up
0
Down
Hi Sibin-

i think i already send this javascript code to check invalid charcters:

function chkSpecialChars(input)

{

var iChars = "<>";

for (var i = 0; i < input.length; i++)

{

if (iChars.indexOf(input.charAt(i)) != -1)

{

alert (

"You are using special characters. \nThese are not allowed.\n Please remove them and try again."); return false;

}

}

return true;

}

use this for the above mentioned problem.

Sibin.rhythm, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sibin.rhythm on: 8/29/2009 [Member] Starter

Up
0
Down
Thank you...Tank you once again

Sibin.rhythm, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response