How do i redirect page after confirmation

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • satyabhaskar
    New Member
    • Dec 2008
    • 32

    How do i redirect page after confirmation

    Actuall im designing my web page, in that i have text box with name book number
    ...what i require is if the user will type a new number which is not in the data base and press enter then i want to display a message box saying the book number is not available weather he want to insert new book into database....
    in the confirm box if he press ok i want to redirect to InsertBook page.else i want to display the same page. actually i have to write this code in the .cs file using java script...i cant able to use java script in .cs file... i wrote by code as follows
    Code:
                    SqlConnection objCon = new SqlConnection(con);
                    SqlDataAdapter objDA = new SqlDataAdapter(fill, objCon);
                    DataSet ds = new DataSet();
                    objDA.Fill(ds, "tblBook");
                    DataTable objDT = ds.Tables[0];               
                    added = objDT.Rows.Count;           
                    if (added == 1)
                    {
                        foreach (DataRow dr in objDT.Rows)
                        {
                            txtAuthor.Text = dr["AuthorName"].ToString();
                            txtBtitle.Text = dr["BookTitle"].ToString();
                        }
                        //GridView1.DataSource=objDT;
                        //GridView1.DataBind();
                    }
                    else
                    {
    
                        Response.Write("<script language='javascript'> var result=confirm('File not found');</script>");
                    }
    my problem is in else part of the above code....of course im able to display a confirm box but i cant make it redirect...can any one help me

    thanks
    Last edited by kenobewan; Jan 4 '09, 11:12 AM. Reason: Code tags
  • Bassem
    Contributor
    • Dec 2008
    • 344

    #2
    You can use this
    Response.Redire ct("InsertBookP age.htm");

    Comment

    • kenobewan
      Recognized Expert Specialist
      • Dec 2006
      • 4871

      #3
      If you simply must do it using JS try registerclients cript method or similar. Good luck.

      Comment

      • liawcv
        New Member
        • Jan 2009
        • 33

        #4
        JavaScript for redirection:
        Code:
        window.location = 'AnotherPage.aspx';

        Comment

        Working...