Ask a Question related to ASP.NET Building Controls, Design and Development.
-
Divya #1
Dynamically loading user control
Hi
I am adding a user control to an aspx page dynamically. This user control has a link button. Hence I have to enclose it in a form tag with runat=server. When I execute the page, I get a javascript runtime error (; expected). The error occurs in the asp generated part of the code. The line where this error occurs is
else {theform = document._ctl0:form1;} in the following part of code
<html><head><meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1"><meta name="CODE_LANGUAGE" Content="C#"><meta name="vs_defaultClientScript" content="JavaScript"><meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5"><title>NMG Digital Marketing System</title><link href= ..\code\css\default.css rel='stylesheet' type='text/css'></head><body><table border="1" width="100%" height="100%"><tr><td align="center" height="20"><h3>NMG Digital Marketing System</h3></td></tr><tr><td align="center" valign="top"><form id="mainForm" runat="server" method=post><script language="javascript"
document.title = "Manage Admin"
parent.parent.parent.identifyFrame(this.name, document.title)
</script><form name="_ctl0:form1" method="post" action="index.aspx?c=admin.admincp.manageadmin" id="_ctl0_form1"><input type="hidden" name="__EVENTTARGET" value="" /><input type="hidden" name="__EVENTARGUMENT" value="" /><input type="hidden" name="__VIEWSTATE" value="dDwtOTU1NjcwNzcxO3Q8O2w8aTwxMD47PjtsPHQ8O2w 8aTwwPjs+O2w8dDw7bDxpPDE+Oz47bDx0PDtsPGk8MT47PjtsP HQ8QDA8cDxwPGw8UGFnZUNvdW50O18hSXRlbUNvdW50O18hRGF 0YVNvdXJjZUl0ZW1Db3VudDtEYXRhS2V5czs+O2w8aTwxPjtpP DE+O2k8MT47bDxpPDMxPjs+Oz4+Oz47Ozs7Ozs7Ozs7PjtsPGk 8MD47PjtsPHQ8O2w8aTwxPjs+O2w8dDw7bDxpPDA+Oz47bDx0P HA8cDxsPFRleHQ7PjtsPDMxOz4+Oz47Oz47Pj47Pj47Pj47Pj4 7Pj47Pj47Pj47PkfgL7dJ8B16d6irfMFLe4UP0jBO" /><script language="javascript"><!-
function __doPostBack(eventTarget, eventArgument)
var theform
if (window.navigator.appName.toLowerCase().indexOf("n etscape") > -1)
theform = document.forms["_ctl0:form1"]
else
theform = document._ctl0:form1
theform.__EVENTTARGET.value = eventTarget.split("$").join(":")
theform.__EVENTARGUMENT.value = eventArgument
theform.submit()
// --></script><table cellspacing="0" cellpadding="3" rules="all" border="1" id="_ctl0_dgUsers" style="height:136px;width:350px;border-collapse:collapse;"><tr><td style="font-weight:bold;">User Email Address</td><td> </td><td> </td></tr><tr><td></td><td style="width:30px;"><a href="javascript:__doPostBack('_ctl0$dgUsers$_ctl2 $_ctl0','')">Edit</a></td><td style="width:30px;"><a href="javascript:__doPostBack('_ctl0$dgUsers$_ctl2 $_ctl1','')">Delete</a></td></tr></table></form></form></td></tr><tr><td align="center" height="20"><i>Copyright 1998 - New Media Gateway, Inc.</i></td></tr></table></body></html
I am loading the static HTML part of the above page from a template file and I am dynamically loading the user control (manageadmin.ascx)
How do I solve this problem? Could someone please help
Thanks
-Divya
Divya Guest
-
Dynamically Loading User Control in PlaceHolder
Hi , I load dynamically a user control in PlaceHolder with the number of fileds in db. When loading user control there is no problem, if returning... -
Dynamically loading user control into Placeholder gives Object reference not set to an instance of an object
I've created user controls that contain listboxes that are dynamically populated from the database. In the html view of the user control... -
Dynamically Adding User Control with Child User Control
I have a user control that has a child user control. If I drag this onto the page, it appears and functions normally. If I attempt to add the... -
How do I dynamically add a user control to a web page?
I have a user control which I created that does not work when I add it dynamically to a web page. My code looks like this. For x = 0 to max... -
Loading/Unloading web user controls dynamically in code - Does this look right?
You ought to check out the DynamicPlaceHolder control instead of using the builtin Placeholder. ... -
John Saunders #2
Re: Dynamically loading user control
"Divya" <divyas@newmediagateway.com> wrote in message
news:0C991F55-DCC2-4784-991F-644765DEB5EC@microsoft.com...has a link button. Hence I have to enclose it in a form tag with> Hi,
>
> I am adding a user control to an aspx page dynamically. This user control
runat=server. When I execute the page, I get a javascript runtime error (;
expected). The error occurs in the asp generated part of the code. The line
where this error occurs is7.1"><meta name="CODE_LANGUAGE" Content="C#"><meta> else {theform = document._ctl0:form1;} in the following part of code -
>
> <html><head><meta name="GENERATOR" Content="Microsoft Visual Studio .NET
name="vs_defaultClientScript" content="JavaScript"><meta
name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5"><title>NMG Digital
Marketing System</title><link href= ..\code\css\default.css
rel='stylesheet' type='text/css'></head><body><table border="1" width="100%"
height="100%"><tr><td align="center" height="20"><h3>NMG Digital Marketing
System</h3></td></tr><tr><td align="center" valign="top"><form id="mainForm"
runat="server" method=post><script language="javascript">action="index.aspx?c=admin.admincp.manageadmin" id="_ctl0_form1"><input> document.title = "Manage Admin";
> parent.parent.parent.identifyFrame(this.name, document.title);
> </script><form name="_ctl0:form1" method="post"
type="hidden" name="__EVENTTARGET" value="" /><input type="hidden"
name="__EVENTARGUMENT" value="" /><input type="hidden" name="__VIEWSTATE"
value="dDwtOTU1NjcwNzcxO3Q8O2w8aTwxMD47PjtsPHQ8O2w 8aTwwPjs+O2w8dDw7bDxpPDE+O
z47bDx0PDtsPGk8MT47PjtsPHQ8QDA8cDxwPGw8UGFnZUNvdW5 0O18hSXRlbUNvdW50O18hRGF0Y
VNvdXJjZUl0ZW1Db3VudDtEYXRhS2V5czs+O2w8aTwxPjtpPDE +O2k8MT47bDxpPDMxPjs+Oz4+O
z47Ozs7Ozs7Ozs7PjtsPGk8MD47PjtsPHQ8O2w8aTwxPjs+O2w 8dDw7bDxpPDA+Oz47bDx0PHA8c
DxsPFRleHQ7PjtsPDMxOz4+Oz47Oz47Pj47Pj47Pj47Pj47Pj4 7Pj47Pj47PkfgL7dJ8B16d6irf
MFLe4UP0jBO" /><script language="javascript"><!--border="1" id="_ctl0_dgUsers"> function __doPostBack(eventTarget, eventArgument) {
> var theform;
> if (window.navigator.appName.toLowerCase().indexOf("n etscape") > -1) {
> theform = document.forms["_ctl0:form1"];
> }
> else {
> theform = document._ctl0:form1;
> }
> theform.__EVENTTARGET.value = eventTarget.split("$").join(":");
> theform.__EVENTARGUMENT.value = eventArgument;
> theform.submit();
> }
> // --></script><table cellspacing="0" cellpadding="3" rules="all"
style="height:136px;width:350px;border-collapse:collapse;"><tr><td
style="font-weight:bold;">User Email
Address</td><td> </td><td> </td></tr><tr><td></td><td
style="width:30px;"><a
href="javascript:__doPostBack('_ctl0$dgUsers$_ctl2 $_ctl0','')">Edit</a></td>
<td style="width:30px;"><a
href="javascript:__doPostBack('_ctl0$dgUsers$_ctl2 $_ctl1','')">Delete</a></t
d></tr></table></form></form></td></tr><tr><td align="center"
height="20"><i>Copyright 1998 - New Media Gateway,
Inc.</i></td></tr></table></body></html>and I am dynamically loading the user control (manageadmin.ascx).>
> I am loading the static HTML part of the above page from a template fileThis is a known problem in ASP.NET 1.1. There is a patch, but I'm afraid> How do I solve this problem? Could someone please help?
I've misplaced the number of the KB article.
--
John Saunders
johnwsaundersiii at hotmail
John Saunders Guest
-
John Saunders #3
Re: Dynamically loading user control
"Divya" <divyas@newmediagateway.com> wrote in message
news:53A39787-78FF-40C0-9F0B-593C48E15EB4@microsoft.com...about this, got the fix, installed it and it executed fine. But now, I seem> Hi John,
>
> Thanks for the tip. I looked up the KB article and contacted Microsoft
to have another problem. I am guessing that it is due to the patch (for
..Net) that I installed. I have an aspx page dynamically loading a user
control. The user control has a datagrid with a column of 'edit' link
buttons. When the user clicks on one of the edit buttons, I want to redirect
to another aspx page with the itemIndex of the row (that was clicked), sent
as a query string.throws a javascript runtime error -> When I execute this and click an edit button link in the datagrid, itDivya, I didn't see this problem after applying the patch. However:> '__EVENTTARGET' is null or not an object.
> In the source, it points to the line -
> theform.__EVENTTARGET.value = eventTarget.split("$").join(":");
....
occurs -> Below is the entire source (generated by .Net) of the page when the error7.1"><meta name="CODE_LANGUAGE" Content="C#"><meta>
> <html><head><meta name="GENERATOR" Content="Microsoft Visual Studio .NET
name="vs_defaultClientScript" content="JavaScript"><meta
name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5"><title>NMG Digital
Marketing System</title><link href= ..\code\css\default.css
rel='stylesheet' type='text/css'></head><body><table border="1" width="100%"
height="100%"><tr><td align="center" height="20"><h3>NMG Digital Marketing
System</h3></td></tr><tr><td align="center" valign="top"><form id="mainForm"
runat="server" method=post><form name="__aspnetForm" method="post"
action="index.aspx?c=test" id="__aspnetForm">
I notice that you have a form called "mainForm". You should find a way to do
without it. There should only be one form on the page, as far as ASP.NET is
concerned. At the very least you should check to see if the same problem
happens on a page without the nested forms.
--
John Saunders
johnwsaundersiii at hotmail
John Saunders Guest



Reply With Quote

