Click here to Skip to main content
15,915,857 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionFormat String for Decimal {0:D2} Pin
OldDog.Net3-Oct-06 9:25
OldDog.Net3-Oct-06 9:25 
AnswerRe: Format String for Decimal {0:D2} Pin
Jon Sagara3-Oct-06 9:50
Jon Sagara3-Oct-06 9:50 
GeneralRe: Format String for Decimal {0:D2} Pin
OldDog.Net4-Oct-06 2:52
OldDog.Net4-Oct-06 2:52 
AnswerRe: Format String for Decimal {0:D2} Pin
Guffa3-Oct-06 9:51
Guffa3-Oct-06 9:51 
GeneralRe: Format String for Decimal {0:D2} Pin
OldDog.Net4-Oct-06 2:56
OldDog.Net4-Oct-06 2:56 
AnswerRe: Format String for Decimal {0:D2} Pin
Guffa4-Oct-06 6:07
Guffa4-Oct-06 6:07 
QuestionProblem with ButtonEvents on dynamic UserContols Pin
Ibana3-Oct-06 7:44
Ibana3-Oct-06 7:44 
AnswerRe: Problem with ButtonEvents on dynamic UserContols Pin
e-laj3-Oct-06 11:33
e-laj3-Oct-06 11:33 
See,

Recall that the framework create the controls tree only for static controls - this is why the event of the dynamic controls could not reached there targets when the page is posted back - so this is your job, as i describe in a minute.

The problem is that the page controls tree is built before the page load - and events that should be fired target to controls resolved in that stage. Hence if your dynamic controls are not existed in this level - WITH THE SAME ID AS THEY HAD IN THE PREVIOUS POSTBACK - the events will not be fired.

So, a good solution will be:

1 - When you create the controls assigned them a unique id. Aparantly you will do it in the Page_Load, you should do it only if the page was not post bask. Dont forget to add you controls to the Controls Collection of their container. For example - if you add these controls directly on the form - Write: Page.Controls.Add(...your control here).

Page_load...
- if not post back
- Create the control
- Assigned the created control a unique id
- Add the created control to its container "Controls" collection.


2 - When you create these controls - put some information in the ViewState so you can rebuild these controls when the page will be posted-back:

- ViewState[some key]=information.

The information should be encoded in a way that can describe you in the next step what controls were existed before the post back.


3 - Override the TrackViewState method of the page and rebuild the dynamic part of your page using the information you saved in the ViewState. Again dont forget to add these dynamic created controls to your Controls collection.

That is all!


If the dynamic controls that you are creating are always the same (obviously they are not) you could be satisfied with the Page_Load part without checking the PostBack status.

Best regards,
e-laj

GeneralRe: Problem with ButtonEvents on dynamic UserContols Pin
nguyenvhn3-Oct-06 17:31
nguyenvhn3-Oct-06 17:31 
GeneralRe: Problem with ButtonEvents on dynamic UserContols Pin
Ibana5-Oct-06 12:52
Ibana5-Oct-06 12:52 
AnswerRe: Problem with ButtonEvents on dynamic UserContols Pin
e-laj5-Oct-06 21:45
e-laj5-Oct-06 21:45 
Questionhow make make sorting and paging both work togeather? Pin
jwrz200t3-Oct-06 6:27
jwrz200t3-Oct-06 6:27 
AnswerRe: how make make sorting and paging both work togeather? Pin
laocat20036-Oct-06 5:06
laocat20036-Oct-06 5:06 
Question(Ultra)WebTabs from Ingragistic Pin
julie763-Oct-06 6:22
julie763-Oct-06 6:22 
AnswerRe: (Ultra)WebTabs from Ingragistic Pin
Member 964-Oct-06 13:23
Member 964-Oct-06 13:23 
QuestionWrong button clicked when user presses "Enter" key Pin
Goalie353-Oct-06 5:28
Goalie353-Oct-06 5:28 
AnswerRe: Wrong button clicked when user presses "Enter" key Pin
ToddHileHoffer3-Oct-06 5:47
ToddHileHoffer3-Oct-06 5:47 
QuestionHow to get Focus on one Button,if two buttons exists on the same form Pin
ravindradonkada3-Oct-06 3:07
ravindradonkada3-Oct-06 3:07 
AnswerRe: How to get Focus on one Button,if two buttons exists on the same form Pin
Sathesh Sakthivel3-Oct-06 3:15
Sathesh Sakthivel3-Oct-06 3:15 
AnswerRe: How to get Focus on one Button,if two buttons exists on the same form Pin
ToddHileHoffer3-Oct-06 4:55
ToddHileHoffer3-Oct-06 4:55 
AnswerRe: How to get Focus on one Button,if two buttons exists on the same form Pin
vikram1383-Oct-06 17:36
vikram1383-Oct-06 17:36 
Questionpage load event not called Pin
Deepak the Cool3-Oct-06 1:23
Deepak the Cool3-Oct-06 1:23 
AnswerRe: page load event not called Pin
CWIZO3-Oct-06 6:37
CWIZO3-Oct-06 6:37 
QuestionWebservice and COM object Pin
Talal Sultan3-Oct-06 1:22
Talal Sultan3-Oct-06 1:22 
QuestionAvoid Datagrid Refresh Pin
kavithapuranik3-Oct-06 0:40
kavithapuranik3-Oct-06 0:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.