Form and redirect question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • preeshma
    New Member
    • Aug 2006
    • 2

    Form and redirect question

    I am working in Visual Studio 2005 and ASP.NET 2.0. I have created a customer form and I need to insert the details into the database as well as when I click the submit button I have to go to another .aspx page.

    I have done it in Formview.
    The code is
    <asp:LinkButt on ID="insertButto n" runat="server" CauseValidation ="True" CommandName="in sert" PostBackUrl="`/Clinic.aspx" Text="insert"></asp:LinkButton>

    Clinic.aspx is the page I finsih to go after inserting the data into the database.

    If I am not giving the "PostUrl" then the data is inserting into the database.But I can't do both in one click.

    Hope someone can help me

    regards
    preeshma
  • nmsreddi
    Contributor
    • Jul 2006
    • 366

    #2
    hi

    you said the problem is when you are not giving the posturl.what is the problem if you use posturl.why you r avoiding that can you specify the reason so that i can help you




    regards

    nmsreddi

    Comment

    • preeshma
      New Member
      • Aug 2006
      • 2

      #3
      Using asp button(FormView ) I am trying to insert the data from the form into the database and at the same time want to move on to another page indicating the succes of insertion.

      My code:
      <asp:Button ID="InsertButto n" runat="server" CausesValidatio n="True" CommandName="In sert"
      Text="Submit" PostBackUrl="~/ClinicDownload. aspx"></asp:Button>

      If I give PostbackUrl it is moving on to another page, but no insertion is taking place. If I don't give the PostBackUrl then I can insert. I want to do both in one click....

      Regards
      preeshma

      Originally posted by nmsreddi
      hi

      you said the problem is when you are not giving the posturl.what is the problem if you use posturl.why you r avoiding that can you specify the reason so that i can help you




      regards

      nmsreddi

      Comment

      • nmsreddi
        Contributor
        • Jul 2006
        • 366

        #4
        hello

        actually when you are saving data to the database in the button click it self
        just check it out ,if not first save data to the database then following write code for redirecting in that button click method only. i think you are giving postback url inline code just avoid it and write the code for redirecting in the button click it self after the save method(method which you write for inswerting in to database)

        even now i dint get your problem exactly but hope may help

        if problem not solved try to elaporate any post as soon as possible

        Comment

        • Fasih Akbar
          New Member
          • Sep 2006
          • 3

          #5
          Hi,

          Save the data in the database as u r doing on button click.....then after saving
          write the following line of code to redirect on to the next page.

          Response.Redire ct("YourPage.as px");

          If U R passing values on to the next page then use this line of code as

          Response.Redire ct("YourPage.as px?value1="+my_ id);

          If u want to access this value on the next page then access the value which is in the variable "value1" with this line in the page load:

          string abc = Request.Params["value1"];

          now u can use abc value on this new page.

          Thanks.

          Fasih

          Comment

          Working...