PostBackUrl
-
Here's my problem: I have a button and when I click it I want to open a new page. I know that I can do this thing very easy by setting the PostBackUrl property of the button. But here's what I want to do: on my page I have a textbox and, for example when I press the button I want to test the text from the TextBox and if it's ok I want to show the new page; if not I want to display a message. I want to do that using c# language, and not JavaScript. I've tried this:
protected void Button1_Click(object sender, EventArgs e) { if (TextBox1.Text == "something") Button1.PostBackUrl = "NewPage.aspx"; else .................... }
Can anyone help me please? -
Here's my problem: I have a button and when I click it I want to open a new page. I know that I can do this thing very easy by setting the PostBackUrl property of the button. But here's what I want to do: on my page I have a textbox and, for example when I press the button I want to test the text from the TextBox and if it's ok I want to show the new page; if not I want to display a message. I want to do that using c# language, and not JavaScript. I've tried this:
protected void Button1_Click(object sender, EventArgs e) { if (TextBox1.Text == "something") Button1.PostBackUrl = "NewPage.aspx"; else .................... }
Can anyone help me please?if i understand you correctly , when the Textbox value is equal to what you want a use to be transfered to another page else show the message(Error), if so , then you can do it this way
protected void Button1\_Click(object sender, EventArgs e) { if (TextBox1.Text == "something") { Response.Redirect("NewPage.aspx",false); } else { // Show your Error message here } }
Hope this is what you are looking for. One more thing , Dont post the same thing twice , its not allowed here.
Vuyiswa Maseko, Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code. C#/VB.NET/ASP.NET/SQL7/2000/2005/2008 http://www.vuyiswamaseko.com vuyiswa@its.co.za http://www.itsabacus.co.za/itsabacus/