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

B

bill

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
 
M

Mike

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/
 
B

bill

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top