By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,636 Members | 1,945 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,636 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Apr 12 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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/

Apr 12 '06 #2

P: n/a
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" <mi**********@xquisoft.com> wrote in message
news:11**********************@e56g2000cwe.googlegr oups.com...
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/

Apr 12 '06 #3

P: n/a
No, I would use Response.Redirect.

Apr 13 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.