Re: [aus-dotnet] ASP.NET Refresh


    [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
    • From: Greg
    • Subject: Re: [aus-dotnet] ASP.NET Refresh
    • Date: Mon, 13 Dec 2004 09:02:06 +1100

    why not use the button click event to insert the data It will only run if the button is clicked
    ----- Original Message ----- From: Quang Huynh To: dotnet@xxxxxxxxxxx Sent: Sunday, December 12, 2004 10:43 PM Subject: [aus-dotnet] ASP.NET Refresh

    Hi All,

     

    I?m stuck with a problem whereby I cannot for the life of me stop insertions to a database each time I refresh a page.

    Basically I have a .aspx page, a person enters some comments, comments go to DB, and then gets displayed on the page, behaves like a forum message I suppose.

     

    Here is what I have in my page_load:

     

    Page_Load()

    {

                Setup_Database_Connection;

                Sql_Retrieve_Messages_Stored_Procedure;

                Sql_ExecuteReader_To_Display_Messages;

     

                If(Page.IsPostBack) // so here they press submit when filling out comments form

                {

                            Sql_Insert_Message_Stored_Procedure;

                }

    }

     

    It seems that each time I refresh, data is inserted, does a refresh constitute a postback?

    How can I overcome this problem? I?ve tried resetting the text boxes to String.Empty and then having a predicate so to only insert if text boxes are not empty, but it still does the insertion with the same data in memory somewhere.

    Tried clearing the StoredProcedure parameters.

     

    Any Ideas?

     

    Quang

     




    (Click here for more information on the aus-dotnet mailling list)