Click here to Skip to main content
15,886,026 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Index Search... Pin
Moghan24-Apr-08 18:54
Moghan24-Apr-08 18:54 
GeneralRe: Index Search... Pin
Harini N K24-Apr-08 18:52
Harini N K24-Apr-08 18:52 
GeneralRe: Index Search... Pin
Moghan24-Apr-08 18:59
Moghan24-Apr-08 18:59 
GeneralProblem with Loading an User Control dynamically [modified] Pin
lovedotnet24-Apr-08 18:24
lovedotnet24-Apr-08 18:24 
GeneralRe: Problem with Loading an User Control dynamically Pin
AlexeiXX324-Apr-08 18:43
AlexeiXX324-Apr-08 18:43 
GeneralRe: Problem with Loading an User Control dynamically Pin
lovedotnet25-Apr-08 0:56
lovedotnet25-Apr-08 0:56 
GeneralRe: Problem with Loading an User Control dynamically Pin
AlexeiXX325-Apr-08 5:17
AlexeiXX325-Apr-08 5:17 
GeneralRe: Problem with Loading an User Control dynamically Pin
Mircea Grelus25-Apr-08 12:12
Mircea Grelus25-Apr-08 12:12 
As AlexeiXX3 mentioned, dynamically generated controls are not recreated after the page postbacks.

The thing is that the postback resets the page to it's original state, so any information regarding the dynamically created controls is lost. Why is that? Because the Page class is stateless. The Page recreates child controls based on the tags in the aspx files, so your controls not being present there are not shown. What you need to do is recreate the controls in the OnInit event or any event that fires before PageLoad, or in PageLoad if you do a check to see is the page is posted back. See this article[^] as an example.

The thing to keep in mind is that when recreating the controls to assign them the same ID they previously had. This way you will retain the state of the controls. That's because when you postback a page the values of the controls are saved in the viewstate, but when state is restored to the controls, it actually looks for the controls with the coresponding ID's on the page. If it can find them it will restore them. So you don't have to worry about state as long as you recreate your controls correctly.


Cheers,
Mircea
"Pay people peanuts and you get monkeys" - David Ogilvy

QuestionHow to get radiobutton value inside a button click event. [modified] Pin
chakran24-Apr-08 18:06
chakran24-Apr-08 18:06 
AnswerRe: How to get radiobutton value inside a button click event. Pin
AlexeiXX324-Apr-08 18:26
AlexeiXX324-Apr-08 18:26 
GeneralRe: How to get radiobutton value inside a button click event. Pin
chakran24-Apr-08 18:56
chakran24-Apr-08 18:56 
GeneralRe: How to get radiobutton value inside a button click event. Pin
AlexeiXX324-Apr-08 19:01
AlexeiXX324-Apr-08 19:01 
GeneralRe: How to get radiobutton value inside a button click event. Pin
chakran24-Apr-08 19:08
chakran24-Apr-08 19:08 
GeneralRe: How to get radiobutton value inside a button click event. Pin
chakran24-Apr-08 20:38
chakran24-Apr-08 20:38 
GeneralRe: How to get radiobutton value inside a button click event. Pin
AlexeiXX325-Apr-08 5:23
AlexeiXX325-Apr-08 5:23 
GeneralChallenge - DetailsView and Calendar problem Pin
Ekjon24-Apr-08 11:59
Ekjon24-Apr-08 11:59 
GeneralRe: Challenge - DetailsView and Calendar problem [modified] Pin
AlexeiXX324-Apr-08 18:31
AlexeiXX324-Apr-08 18:31 
GeneralRe: Challenge - DetailsView and Calendar problem Pin
AlexeiXX325-Apr-08 6:18
AlexeiXX325-Apr-08 6:18 
GeneralRe: Challenge - DetailsView and Calendar problem Pin
Ekjon25-Apr-08 7:26
Ekjon25-Apr-08 7:26 
GeneralRe: Challenge - DetailsView and Calendar problem Pin
AlexeiXX325-Apr-08 6:22
AlexeiXX325-Apr-08 6:22 
QuestionIs it possible to display a gridview based on a session variable Pin
ahlaj7724-Apr-08 8:19
ahlaj7724-Apr-08 8:19 
GeneralRe: Is it possible to display a gridview based on a session variable Pin
Ekjon24-Apr-08 11:36
Ekjon24-Apr-08 11:36 
GeneralRe: Is it possible to display a gridview based on a session variable Pin
N a v a n e e t h24-Apr-08 17:07
N a v a n e e t h24-Apr-08 17:07 
GeneralRe: Is it possible to display a gridview based on a session variable Pin
AlexeiXX324-Apr-08 18:50
AlexeiXX324-Apr-08 18:50 
QuestionRe: Is it possible to display a gridview based on a session variable Pin
ahlaj7725-Apr-08 2:34
ahlaj7725-Apr-08 2:34 

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.