Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. PostBackUrl

PostBackUrl

Scheduled Pinned Locked Moved ASP.NET
helpcsharpjavascripttutorialquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Munteanu Ciprian
    wrote on last edited by
    #1

    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?

    V 1 Reply Last reply
    0
    • M Munteanu Ciprian

      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?

      V Offline
      V Offline
      Vimalsoft Pty Ltd
      wrote on last edited by
      #2

      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/

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups