Can I fire button click event without firing pagel

2019-08-07 05:56发布

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;)

1条回答
一夜七次
2楼-- · 2019-08-07 06:49

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?

查看更多
登录 后发表回答