Tolga Evcimen
Tolga Evcimen

Reputation: 7352

Can I fire button click event without firing pageload event?

I have a button on my page and and few textboxes which alters their context on page_load event. when I open the page for the first time it loads random data from a database to textboxes with a function in pageload and also I create those textboxes dynamically. what I want is to make some changes on textboxes texts and click the button than send new context of textboxes to database. But when I click on button, PageLoad event fires again and It regenerates the textboxes and the context of them alter naturally since they are newly created textboxes. I tried to use "if(!Page.isPostBack)" in pageload but then the textboxes and related objects are not being created and they become null.

how can I overcome this problem? best thing I can think of is to find some way to fire buttons click event without firing PageLoad event, but I dont know how can I do it.

any help would be appreciated;)

Upvotes: 1

Views: 6193

Answers (1)

Pankaj
Pankaj

Reputation: 10095

From Comments

Can you regenerate the Textbox on each Page load Execution? and data assignment to these Textbox should be under !Page.IsPostback. All you have to do is to keep the IDs of the Textbox in ViewState only first time page load and next regeneration of Textbox will have the previous stored ID and you also have to store the ID corresponding data in ViewState. Makes sense?

Upvotes: 1

Related Questions