Seeking advice - should I use server.transfer after a custom event fires?

Discussion in 'ASP .Net' started by bill, Apr 12, 2006.

  1. bill

    bill Guest

    I am using VS2005 to build a web form dynamically.

    I'm using AddHandler to connect a custom event handler to the TextChanged
    event of dynamically added textbox controls. Data entered in the
    dynamically added textbox controls is saved to a database in the custom
    event handler.

    The custom event handler fires when the page posts back. I have a menu
    control which causes a postback, and the custom event handler then fires if
    a textbox was changed.

    After the custom event handler is finished responding to TextChanged events,
    the MenuItemClick event of the menu control fires. This loads a new page
    based on the menu selection, which is captured in the MenuItemClick event.

    Since I have to 're-add' the previous controls in the Page_Init event so the
    custom TextChanged event will fire, the only way I could figure out to load
    the new page was to use Server.transfer when the MenuItemClick event occurs.
    I use a query string to pass along the menu selected value and other needed
    data.

    Is this the best way to manage this situation? It seems to work OK, but it
    seems kludgy.

    Thanks
    Bill
     
    bill, Apr 12, 2006
    #1
    1. Advertising

  2. bill

    Mike Guest

    Typically, users would not expect changes to a textbox to save if they
    didn't press a save / submit button. Is there a reason you want to
    save when a menu item is selected? Or any other post-back causing
    control?

    Each textbox postback causes a separate database call? That seems a
    little strange. Don't you have a submit button on the page to save all
    the changes at once? If so, get rid of the change handler on each
    textbox and check for changes on each textbox in the one button click
    event (or in a method called by the event).

    If you do that then you don't need to worry if another control besides
    the submit button causes the postback.

    Michael Lang
    XQuiSoft LLC
    http://www.xquisoft.com/
     
    Mike, Apr 12, 2006
    #2
    1. Advertising

  3. bill

    bill Guest

    The page doesn't post back when the textbox is changed.

    The page posts back when a menu selection is made. (There is also a save
    button if the user doesn't want to display a new page after the changes to
    the textboxes are saved, but that is not relevant to my question. I'm
    trying to find the best way to go to a new page.)

    After the page posts back (and the custom event fires, saving any changes to
    text boxes) the MenuItemClick event fires, and I use server.transfer to
    display a new page.

    My question is whether server.transfer is the best way to accomplish this.
    As I said, it seems kludgy.

    Thanks
    Bill

    The page doesn't postback until the menu cont
    "Mike" <> wrote in message
    news:...
    > Typically, users would not expect changes to a textbox to save if they
    > didn't press a save / submit button. Is there a reason you want to
    > save when a menu item is selected? Or any other post-back causing
    > control?
    >
    > Each textbox postback causes a separate database call? That seems a
    > little strange. Don't you have a submit button on the page to save all
    > the changes at once? If so, get rid of the change handler on each
    > textbox and check for changes on each textbox in the one button click
    > event (or in a method called by the event).
    >
    > If you do that then you don't need to worry if another control besides
    > the submit button causes the postback.
    >
    > Michael Lang
    > XQuiSoft LLC
    > http://www.xquisoft.com/
    >
     
    bill, Apr 12, 2006
    #3
  4. bill

    Mike Guest

    No, I would use Response.Redirect.
     
    Mike, Apr 13, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. George K
    Replies:
    3
    Views:
    1,724
    John Saunders
    Nov 25, 2003
  2. Progman
    Replies:
    1
    Views:
    342
    Progman
    Mar 25, 2006
  3. Max2006
    Replies:
    2
    Views:
    1,578
    Walter Wang [MSFT]
    Sep 19, 2007
  4. Replies:
    3
    Views:
    999
  5. Jim
    Replies:
    1
    Views:
    909
    Aaron Bertrand - MVP
    Jan 28, 2004
Loading...

Share This Page