Click here to Skip to main content
16,006,001 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: problem in work with javascript Pin
leckey15-Aug-07 6:14
leckey15-Aug-07 6:14 
GeneralRe: problem in work with javascript Pin
mr.mohsen15-Aug-07 7:15
mr.mohsen15-Aug-07 7:15 
AnswerRe: problem in work with javascript Pin
Guffa15-Aug-07 7:11
Guffa15-Aug-07 7:11 
AnswerRe: problem in work with javascript Pin
ToddHileHoffer15-Aug-07 7:14
ToddHileHoffer15-Aug-07 7:14 
Questionproblem in work with javascript Pin
mr.mohsen15-Aug-07 5:56
mr.mohsen15-Aug-07 5:56 
AnswerWTF? Pin
leckey15-Aug-07 6:11
leckey15-Aug-07 6:11 
GeneralRe: WTF? Pin
Steve Echols15-Aug-07 18:23
Steve Echols15-Aug-07 18:23 
QuestionDynamic User Control loading: Javascript error on Request.Form[...] Pin
Talal Sultan15-Aug-07 5:44
Talal Sultan15-Aug-07 5:44 
Hi all,

I'm trying to load a user control dynamically into a web form. As I understand it, in order for the Placeholder to have a viewstate, I need to load the control in it before the Page load. So I'm trying to do that in the OnPreLoad method.
I have a link button on the web form. When I click it, I would like to load the user control in the placeholder. The first thing I do is save the UniqueID of the link button in the session. Now in order to be able to check which control has triggered the postback, I match the saved value in the session with the value of this.Request.Form["__EVENTTARGET"]. If they are equal, I go ahead and load the control.

Now the issues I'm having:

First, when the page loads for the first time, I have a javascript error that says
'null' is null or not an object Confused | :confused:

The page continues to work however and when I click the link button, the user control is loaded and is displayed.

Now I have a button in the user control, when I click it, the user control disappears again on postback. I'm guessing this is because the placeholder didn't hold the viewstate as I expected. Would that be due to that Javascript error? The code I'm using is this:
if (this.Request.Form["__EVENTTARGET"] == (string)Session["linkID"])
{
    uc = (UserControl)Page.LoadControl("modules/AddFeatureType.ascx");
    PH_AddFeature_AddType.Controls.Add(uc);
}


where uc is declared globally in the page class.

When I remove this code, no javascript error anymore.

So my questions are: 1-Has anyone encountered a similar javascript problem and if yes, what is causing it exactly? 2-Is OnPreLoad the correct method to place the user control load process to maintain viewstate during postbacks?

Any other insights or issues concerning dynamic user control loading are welcome and appreciated.

Thanks.







-- If this is a post that has been helpful to you, please vote for it. Thank you!

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning."
--Rich Cook

AnswerRe: Dynamic User Control loading: Javascript error on Request.Form[...] Pin
Talal Sultan15-Aug-07 6:07
Talal Sultan15-Aug-07 6:07 
QuestionASP.Net page displayed on a PDA problem Pin
bobh052615-Aug-07 5:38
bobh052615-Aug-07 5:38 
QuestionInheritance in web controls Pin
Dermot O S15-Aug-07 3:42
Dermot O S15-Aug-07 3:42 
AnswerRe: Inheritance in web controls Pin
Guffa15-Aug-07 3:48
Guffa15-Aug-07 3:48 
GeneralRe: Inheritance in web controls Pin
Dermot O S15-Aug-07 4:07
Dermot O S15-Aug-07 4:07 
GeneralRe: Inheritance in web controls Pin
Paddy Boyd15-Aug-07 4:37
Paddy Boyd15-Aug-07 4:37 
AnswerRe: Inheritance in web controls Pin
Guffa15-Aug-07 8:16
Guffa15-Aug-07 8:16 
GeneralRe: Inheritance in web controls Pin
Dermot O S15-Aug-07 21:59
Dermot O S15-Aug-07 21:59 
QuestionUnable to start debugging on web server Pin
aquarious202015-Aug-07 3:37
aquarious202015-Aug-07 3:37 
AnswerRe: Unable to start debugging on web server Pin
Michael Sync15-Aug-07 4:49
Michael Sync15-Aug-07 4:49 
GeneralRe: Unable to start debugging on web server Pin
Michael Sync15-Aug-07 5:39
Michael Sync15-Aug-07 5:39 
QuestionEvents not firing after adding a particular User control in ASP.NET 2005 Pin
naresh51115-Aug-07 3:27
naresh51115-Aug-07 3:27 
AnswerRe: Events not firing after adding a particular User control in ASP.NET 2005 Pin
Michael Sync15-Aug-07 5:03
Michael Sync15-Aug-07 5:03 
QuestionWhy is VS creating 2 project folders? Pin
jimbaloo15-Aug-07 3:25
jimbaloo15-Aug-07 3:25 
AnswerRe: Why is VS creating 2 project folders? Pin
Michael Sync15-Aug-07 4:58
Michael Sync15-Aug-07 4:58 
QuestionCheckBoxField Pin
mvyjim15-Aug-07 3:08
mvyjim15-Aug-07 3:08 
QuestionPublic shared classes with asp.net Pin
greekius15-Aug-07 2:24
greekius15-Aug-07 2:24 

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.