Hello Sir,
On Button_click event I have simple code below to compare strings in asp.net

string temp1=Button1.Text;// gives string  "check"
   string temp2="check";  
   if(string.Compare(temp1,temp2)== 0) //but it return  -1
        {
            btnPreview.Text = "complete check";
            
        }

what is wrong with this?
Can anybody help me ..?

oh no...
I find the error..
actually problem is in button text:
There is one space before character check.
so it's not "check" but it's " check"
and I'm trying to compare string "check" with " check" .and obviously it will return -1 during comparing..

So Take Care U all .bcz It may be possible that one simple space can change your correct idea.
thanks....

Hello Sir,
On Button_click event I have simple code below to compare strings in asp.net

string temp1=Button1.Text;// gives string  "check"
   string temp2="check";  
   if(string.Compare(temp1,temp2)== 0) //but it return  -1
        {
            btnPreview.Text = "complete check";
            
        }

what is wrong with this?
Can anybody help me ..?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.