Saturday, March 31, 2012
the assembly 'ASPnetMenu' could not be loaded...
server. can someone please identify whats wrng with it?
all the required dll which was running on the development server was copied
into the production server even the aspnetmenu dll...
but i'm still having this problem...
=== Pre-bind state information ===
LOG: DisplayName = ASPnetMenu, Version=1.5.0.0, Culture=neutral,
PublicKeyToken=9bc9f846553156bb
(Fully-specified)
LOG: Appbase = file:///D:/App/GAR NPI2
LOG: Initial PrivatePath = bin
Calling assembly : NPI, Version=1.0.1924.37987, Culture=neutral,
PublicKeyToken=null.
===
LOG: Publisher policy file is not found.
LOG: No redirect found in host configuration file
(C:\WINDOWS\MICROS~1.NET\FRAMEW~1\V11~1.432\aspnet.config).
LOG: Using machine configuration file from
C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\config\machine.config.
LOG: Post-policy reference: ASPnetMenu, Version=1.5.0.0, Culture=neutral,
PublicKeyToken=9bc9f846553156bb
LOG: Attempting download of new URL
file:///C:/WINDOWS/MICROS~1.NET/FRAMEW~1/V11~1.432/Temporary ASP.NET
Files/root/c3a69742/9fe93016/ASPnetMenu.DLL.
LOG: Attempting download of new URL
file:///C:/WINDOWS/MICROS~1.NET/FRAMEW~1/V11~1.432/Temporary ASP.NET
Files/root/c3a69742/9fe93016/ASPnetMenu/ASPnetMenu.DLL.
LOG: Attempting download of new URL file:///D:/App/GAR
NPI2/bin/ASPnetMenu.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Minor VersionIs the application folder that has the "bin" folder where do you place the
aspnetmenu.dll, marked as an application in IIS? E.g is the bin folder at
correct level in the app hierarchy?
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
"Asha" <Asha@dotnet.itags.org.discussions.microsoft.com> wrote in message
news:6D1D936E-B0FC-445F-AC67-4B185123C343@dotnet.itags.org.microsoft.com...
> hello attach is a problem i'm having after deploying to the production
> server. can someone please identify whats wrng with it?
> all the required dll which was running on the development server was
> copied
> into the production server even the aspnetmenu dll...
> but i'm still having this problem...
> === Pre-bind state information ===
> LOG: DisplayName = ASPnetMenu, Version=1.5.0.0, Culture=neutral,
> PublicKeyToken=9bc9f846553156bb
> (Fully-specified)
> LOG: Appbase = file:///D:/App/GAR NPI2
> LOG: Initial PrivatePath = bin
> Calling assembly : NPI, Version=1.0.1924.37987, Culture=neutral,
> PublicKeyToken=null.
> ===
> LOG: Publisher policy file is not found.
> LOG: No redirect found in host configuration file
> (C:\WINDOWS\MICROS~1.NET\FRAMEW~1\V11~1.432\aspnet.config).
> LOG: Using machine configuration file from
> C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\config\machine.config.
> LOG: Post-policy reference: ASPnetMenu, Version=1.5.0.0, Culture=neutral,
> PublicKeyToken=9bc9f846553156bb
> LOG: Attempting download of new URL
> file:///C:/WINDOWS/MICROS~1.NET/FRAMEW~1/V11~1.432/Temporary ASP.NET
> Files/root/c3a69742/9fe93016/ASPnetMenu.DLL.
> LOG: Attempting download of new URL
> file:///C:/WINDOWS/MICROS~1.NET/FRAMEW~1/V11~1.432/Temporary ASP.NET
> Files/root/c3a69742/9fe93016/ASPnetMenu/ASPnetMenu.DLL.
> LOG: Attempting download of new URL file:///D:/App/GAR
> NPI2/bin/ASPnetMenu.DLL.
> WRN: Comparing the assembly name resulted in the mismatch: Minor Version
>
>
the assembly ASPnetMenu could not be loaded...
server. can someone please identify whats wrng with it?
all the required dll which was running on the development server was copied
into the production server even the aspnetmenu dll...
but i'm still having this problem...
=== Pre-bind state information ===
LOG: DisplayName = ASPnetMenu, Version=1.5.0.0, Culture=neutral,
PublicKeyToken=9bc9f846553156bb
(Fully-specified)
LOG: Appbase = file:///D:/App/GAR NPI2
LOG: Initial PrivatePath = bin
Calling assembly : NPI, Version=1.0.1924.37987, Culture=neutral,
PublicKeyToken=null.
===
LOG: Publisher policy file is not found.
LOG: No redirect found in host configuration file
(C:\WINDOWS\MICROS~1.NET\FRAMEW~1\V11~1.432\aspnet .config).
LOG: Using machine configuration file from
C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\confi g\machine.config.
LOG: Post-policy reference: ASPnetMenu, Version=1.5.0.0, Culture=neutral,
PublicKeyToken=9bc9f846553156bb
LOG: Attempting download of new URL
file:///C:/WINDOWS/MICROS~1.NET/FRAMEW~1/V11~1.432/Temporary ASP.NET
Files/root/c3a69742/9fe93016/ASPnetMenu.DLL.
LOG: Attempting download of new URL
file:///C:/WINDOWS/MICROS~1.NET/FRAMEW~1/V11~1.432/Temporary ASP.NET
Files/root/c3a69742/9fe93016/ASPnetMenu/ASPnetMenu.DLL.
LOG: Attempting download of new URL file:///D:/App/GAR
NPI2/bin/ASPnetMenu.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Minor VersionIs the application folder that has the "bin" folder where do you place the
aspnetmenu.dll, marked as an application in IIS? E.g is the bin folder at
correct level in the app hierarchy?
--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
"Asha" <Asha@dotnet.itags.org.discussions.microsoft.com> wrote in message
news:6D1D936E-B0FC-445F-AC67-4B185123C343@dotnet.itags.org.microsoft.com...
> hello attach is a problem i'm having after deploying to the production
> server. can someone please identify whats wrng with it?
> all the required dll which was running on the development server was
> copied
> into the production server even the aspnetmenu dll...
> but i'm still having this problem...
> === Pre-bind state information ===
> LOG: DisplayName = ASPnetMenu, Version=1.5.0.0, Culture=neutral,
> PublicKeyToken=9bc9f846553156bb
> (Fully-specified)
> LOG: Appbase = file:///D:/App/GAR NPI2
> LOG: Initial PrivatePath = bin
> Calling assembly : NPI, Version=1.0.1924.37987, Culture=neutral,
> PublicKeyToken=null.
> ===
> LOG: Publisher policy file is not found.
> LOG: No redirect found in host configuration file
> (C:\WINDOWS\MICROS~1.NET\FRAMEW~1\V11~1.432\aspnet .config).
> LOG: Using machine configuration file from
> C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\confi g\machine.config.
> LOG: Post-policy reference: ASPnetMenu, Version=1.5.0.0, Culture=neutral,
> PublicKeyToken=9bc9f846553156bb
> LOG: Attempting download of new URL
> file:///C:/WINDOWS/MICROS~1.NET/FRAMEW~1/V11~1.432/Temporary ASP.NET
> Files/root/c3a69742/9fe93016/ASPnetMenu.DLL.
> LOG: Attempting download of new URL
> file:///C:/WINDOWS/MICROS~1.NET/FRAMEW~1/V11~1.432/Temporary ASP.NET
> Files/root/c3a69742/9fe93016/ASPnetMenu/ASPnetMenu.DLL.
> LOG: Attempting download of new URL file:///D:/App/GAR
> NPI2/bin/ASPnetMenu.DLL.
> WRN: Comparing the assembly name resulted in the mismatch: Minor Version
Wednesday, March 28, 2012
The clicking twice hair pulling doesnt do anything problem!
I have a single page in which everything is loaded from user controls based upon a specific value in the URL. The user controls are dynamically loaded (only load the user controls I need based upon the key in the URL). Within the user control is a form with a single button. When I click the button, nothing happens. When I click it again it does a full postback but all user controls are gone and I haven't the slightest idea if it upated or not. Now the form is in an update panel so it shouldn't be doing a post back.
To reiterate:
1. single page (call it default.aspx)
2. click a link with the key in the url (kind of like "?k=1048")
3. default.aspx runs through a case statement and find the key value that matches the URL then loads the user control.
4. user control has form on it
5. click the submit button, nothing happens. Click it again and it does a postback and all user controls are gone (AJAX didn't work).
So, any ideas about having to click twice and also why the update panel doesn't seem to be working?
thanks
^_^
ps. if i put the user control in a completely separate page where it isn't dynamically loaded, things work as intended.
To start with, when using Dynamic Controls, you should already know that you should RECREATE your controls on every page request. Keeping this in mind, you should keep track of which UserControl was loaded before and then reload it again!
Hope this helps,
Regards
That's nice but didn't help at all nor directed me to even an idea
What I did find was that when I removed the triggers from the update panel then the double-clicking went away and it operated as intended. but I wonder what will happen when I have multiple controls on a page that each have an update panel and I update one, will it cause the others to fire as well even with the mode set to conditional.
Does anyone have an idea of this cause that knows what they are talking about.
thanks
The Command event of dynamically loaded controls
I noticed an interesting effect when working with controls that are
dynamically loaded. For instance, on a web form with a PlaceHolder control
named ImageHolder, I dynamically add an image button at runtime:
//-- Code snippet
protected System.Web.UI.WebControls.PlaceHolder ImageHolder;
private void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
LoadDynamicImageButton();
}
private void ImageButton_Click(object sender,
System.Web.UI.ImageClickEventArgs e)
{
Response.Write("Image button clicked");
}
private void LoadDynamicImageButton()
{
ImageButton btn = new ImageButton();
btn.ImageUrl = "Images/Minus.png";
btn.Click += new ImageClickEventHandler(ImageButton_Click);
ImageHolder.Controls.Add(btn);
}
//-- End code snippet
The first time the page loads, the image button is created. When I click it,
it reloads the page but doesn't trigger its ImageClickEventHandler. If I
forcefully run LoadDynamicImageButton(), i.e., remove the IsPostBack check
in Page_Load() to recreate the image, its ImageClickEventHandler is
triggered. This happens with the Command event as well.
It seems that on post-back, if a dynamically loaded control is not loaded,
then its event handler is not wired. Its properties such as CommandName and
CommandArgument, OTOH, persists from the last load.
The problem is that if I dynamically load up the PlaceHolder control with
different controls according to the button clicked, this behavior forces all
those controls to be loaded twice - first to load all default controls just
to wire up their event handlers, then to reload them again according to the
event. There are also other factors, such as the assigning a differnet
ImageUrl, that seem to affect whether or not the event handler is triggered.
I'm still working on it to hopefully isolate the problem.
Is there a workaround?
Thanks,
Donald XieHi Donald,
Thanks for posting in the community!
From your description, you dynamically add some command controls such as
button or ImageButton into a webform within a placeholder.(in the page_load
event when the page is first loaded). Also, you registered a "Click" event
handler for the dynamicly added control. However, you found that when you
clicked the control , its event handler hadn't been called and if you did
the adding and registering event handler operation every time the page is
loaded in Page_load, it worked well, yes?
I've tested the code you provided and also tried using other controls such
as Button and did encoutnered the same problem. Currently, I am finding
proper resource to assist you and we will update as soon as posible. In the
meantime, if you have any new findings, please feel free to post here.
Regards,
Steven Cheng
Microsoft Online Support
Get Secure! www.microsoft.com/security(This posting is provided "AS IS",
with no warranties, and confers no rights.)
Hi Donald,
This is normal behavior and results from the way ASP.NET remembers the old
value for that text box in order to determine if the new value is different.
Each time the form is sent to the browser, ASP.NET stores the current text
box value (and other controls) in a hidden field which it sends to the
browser. When the browser posts the page back, the hidden field is sent to
the server along with the rest of the form. ASP.NET parses the list of old
values from the hidden field and attempts to associate each value with a
control. Then it compares the new value of the control with the old value
and triggers events.
The text box must be recreated to allow ASP.NET to associate it with the
old value from the hidden field. Only then can ASP.NET compare the new and
old values.
Here is a code sample which demonstrates one text box that correctly
triggers the changed event and three text boxes which fail for each of
three reasons.
**** HTML
<form id="Form1" method="post" runat="server">
<P>This sample contains a series of text boxes added to the page<BR>
programmatically with Controls.Add. The variations in these<BR>
text boxes demonstrate how to (and how not to) add a control<BR>
so that it can fire an event.<BR>
<BR>
</P>
<asp:panel id="Panel1" runat="server">
<P>
<asp:Label id="Label5" runat="server" Width="115px"> With
ViewState:</asp:Label>
<asp:PlaceHolder id="PlaceHolder1"
runat="server"></asp:PlaceHolder>
<asp:Label id="Label1" runat="server" Width="368px"
EnableViewState="False"></asp:Label></P>
<P>
<asp:Label id="Label6" runat="server" Width="115px" Height="19"> No
ViewState:</asp:Label>
<asp:PlaceHolder id="PlaceHolder2"
runat="server"></asp:PlaceHolder>
<asp:Label id="Label2" runat="server" Width="368px"
EnableViewState="False"></asp:Label></P>
<P>
<asp:Label id="Label7" runat="server" Width="115px"
Height="19px">Controls.AddAt:</asp:Label>
<asp:Label id="Label3" runat="server" Width="368px"
EnableViewState="False"></asp:Label></P>
<P>
<asp:Label id="Label8" runat="server" Width="115px"
Height="19px">!IsPostBack:</asp:Label>
<asp:PlaceHolder id="PlaceHolder4"
runat="server"></asp:PlaceHolder>
<asp:Label id="Label4" runat="server" Width="368px"
EnableViewState="False"></asp:Label></P>
</asp:panel>
<P><asp:button id="Button1" runat="server" Text="Submit" Width="100px"
Height="27px"></asp:button></P>
<P><hr></P>
<P>As you can see through experimenting with the above, the text<BR>
box labeled "With ViewState" is the only one that works properly.<BR>
<BR>
The "No ViewState" and the "Controls.AddAt" text boxes both<BR>
fire their changed events whenever they contain text, even if that<BR>
text has not changed.<BR>
<BR>
The "!IsPostBack" text box simply disappears upon postback.</P>
</form
**** CODE
private void Page_Load(object sender, System.EventArgs e)
{
System.Web.UI.WebControls.TextBox MyTextBox;
MyTextBox = new TextBox();
MyTextBox.ID = "TextBox1";
MyTextBox.EnableViewState=true;
PlaceHolder1.Controls.Add(MyTextBox);
MyTextBox.TextChanged += new
System.EventHandler(this.TextBox_TextChanged);
MyTextBox = new TextBox();
MyTextBox.ID = "TextBox2";
MyTextBox.EnableViewState=false;
PlaceHolder2.Controls.Add(MyTextBox);
MyTextBox.TextChanged += new
System.EventHandler(this.TextBox_TextChanged);
MyTextBox = new TextBox();
MyTextBox.ID = "TextBox3";
MyTextBox.EnableViewState=true;
Panel1.Controls.AddAt(15,MyTextBox);
MyTextBox.TextChanged += new
System.EventHandler(this.TextBox_TextChanged);
if(!IsPostBack)
{
MyTextBox = new TextBox();
MyTextBox.ID = "TextBox4";
MyTextBox.EnableViewState=true;
PlaceHolder4.Controls.Add(MyTextBox);
MyTextBox.TextChanged += new
System.EventHandler(this.TextBox_TextChanged);
}
}
private void TextBox_TextChanged(object sender, System.EventArgs e)
{
TextBox txtBoxSender = (TextBox)sender;
string strTextBoxID = txtBoxSender.ID;
switch(strTextBoxID)
{
case "TextBox1":
Label1.Text = "Changed";
break;
case "TextBox2":
Label2.Text = "Changed";
break;
case "TextBox3":
Label3.Text = "Changed";
break;
case "TextBox4":
Label4.Text = "Changed";
break;
}
}
--
Please see these articles for more information.
Adding Controls to a Web Forms Page Programmatically
http://msdn.microsoft.com/library/e...gcontrolstowebf
ormspageprogrammatically.asp
HOW TO: Dynamically Create Controls in ASP.NET by Using Visual C# .NET
http://support.microsoft.com/defaul...kb;EN-US;317794
Does this answer your question?
Thank you, Mike
Microsoft, ASP.NET Support Professional
Microsoft highly recommends to all of our customers that they visit the
http://www.microsoft.com/protect site and perform the three straightforward
steps listed to improve your computers security.
This posting is provided "AS IS", with no warranties, and confers no rights.
-------
> From: "Donald Xie" <donald_xie@dotnet.itags.org.msdn.nospam>
> Subject: The Command event of dynamically loaded controls
> Date: Fri, 30 Jan 2004 16:52:00 +0800
> Lines: 54
> X-Priority: 3
> X-MSMail-Priority: Normal
> X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
> Message-ID: <#C2U35w5DHA.2580@dotnet.itags.org.TK2MSFTNGP11.phx.gbl>
> Newsgroups: microsoft.public.dotnet.framework.aspnet
> NNTP-Posting-Host: 202.181.80.84
> Path:
cpmsftngxa07.phx.gbl!cpmsftngxa10.phx.gbl!TK2MSFTN GXA05.phx.gbl!TK2MSFTNGP08
.phx.gbl!TK2MSFTNGP11.phx.gbl
> Xref: cpmsftngxa07.phx.gbl microsoft.public.dotnet.framework.aspnet:206364
> X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
> Hi,
> I noticed an interesting effect when working with controls that are
> dynamically loaded. For instance, on a web form with a PlaceHolder control
> named ImageHolder, I dynamically add an image button at runtime:
> //-- Code snippet
> protected System.Web.UI.WebControls.PlaceHolder ImageHolder;
> private void Page_Load(object sender, System.EventArgs e)
> {
> if (!IsPostBack)
> LoadDynamicImageButton();
> }
> private void ImageButton_Click(object sender,
> System.Web.UI.ImageClickEventArgs e)
> {
> Response.Write("Image button clicked");
> }
> private void LoadDynamicImageButton()
> {
> ImageButton btn = new ImageButton();
> btn.ImageUrl = "Images/Minus.png";
> btn.Click += new ImageClickEventHandler(ImageButton_Click);
> ImageHolder.Controls.Add(btn);
> }
> //-- End code snippet
> The first time the page loads, the image button is created. When I click
it,
> it reloads the page but doesn't trigger its ImageClickEventHandler. If I
> forcefully run LoadDynamicImageButton(), i.e., remove the IsPostBack check
> in Page_Load() to recreate the image, its ImageClickEventHandler is
> triggered. This happens with the Command event as well.
> It seems that on post-back, if a dynamically loaded control is not loaded,
> then its event handler is not wired. Its properties such as CommandName
and
> CommandArgument, OTOH, persists from the last load.
> The problem is that if I dynamically load up the PlaceHolder control with
> different controls according to the button clicked, this behavior forces
all
> those controls to be loaded twice - first to load all default controls
just
> to wire up their event handlers, then to reload them again according to
the
> event. There are also other factors, such as the assigning a differnet
> ImageUrl, that seem to affect whether or not the event handler is
triggered.
> I'm still working on it to hopefully isolate the problem.
> Is there a workaround?
> Thanks,
> Donald Xie
Thanks for the excellent explanation, Mike. Yes that answers my question.
Now I'm trying to find a good solution for my problem. In a nutshell, I need
to load a hierarchical list of folders and files from a database and display
them on a tree - very much the same as the MSDN Library deeptree.asp. The
number of nodes is potentially large, so I'll only load all top level
folders plus folders in the branch selected by the user. Only one branch can
be expanded each time. My users can click a folder node to expand or
collapse it, based on the selected folder's state.
Since my client doesn't want to use a third party tree control, my first
thought i\was to programmatically create a list of ImageButton/LinkButton
pairs to display the folders. This dynamic control's behavior means that:
1. I'll need to load the folder list in the first pass to wire up the
controls and corresponding event handlers. After it's loaded, the event
handler will fire and give me the selected folder. Then,
2. I'll then load the folder list again with the selected folder
expanded/collapsed.
It doesn't seem like a very efficient solution now because it requires two
trips to the database to load the folder list. Caching doesn't sound very
attractive either because list can be quite big and changes frequently.
Any suggestions are very much appreciated.
Cheers,
Donald Xie
""Mike Moore [MSFT]"" <michmo@dotnet.itags.org.online.microsoft.com> wrote in message
news:AXcHok55DHA.3032@dotnet.itags.org.cpmsftngxa07.phx.gbl...
> Hi Donald,
> This is normal behavior and results from the way ASP.NET remembers the old
> value for that text box in order to determine if the new value is
different.
> Each time the form is sent to the browser, ASP.NET stores the current text
> box value (and other controls) in a hidden field which it sends to the
> browser. When the browser posts the page back, the hidden field is sent to
> the server along with the rest of the form. ASP.NET parses the list of old
> values from the hidden field and attempts to associate each value with a
> control. Then it compares the new value of the control with the old value
> and triggers events.
> The text box must be recreated to allow ASP.NET to associate it with the
> old value from the hidden field. Only then can ASP.NET compare the new and
> old values.
> Here is a code sample which demonstrates one text box that correctly
> triggers the changed event and three text boxes which fail for each of
> three reasons.
>
> **** HTML
> <form id="Form1" method="post" runat="server">
> <P>This sample contains a series of text boxes added to the page<BR>
> programmatically with Controls.Add. The variations in these<BR>
> text boxes demonstrate how to (and how not to) add a control<BR>
> so that it can fire an event.<BR>
> <BR>
> </P>
> <asp:panel id="Panel1" runat="server">
> <P>
> <asp:Label id="Label5" runat="server" Width="115px"> With
> ViewState:</asp:Label>
> <asp:PlaceHolder id="PlaceHolder1"
> runat="server"></asp:PlaceHolder>
> <asp:Label id="Label1" runat="server" Width="368px"
> EnableViewState="False"></asp:Label></P>
> <P>
> <asp:Label id="Label6" runat="server" Width="115px" Height="19"> No
> ViewState:</asp:Label>
> <asp:PlaceHolder id="PlaceHolder2"
> runat="server"></asp:PlaceHolder>
> <asp:Label id="Label2" runat="server" Width="368px"
> EnableViewState="False"></asp:Label></P>
> <P>
> <asp:Label id="Label7" runat="server" Width="115px"
> Height="19px">Controls.AddAt:</asp:Label>
> <asp:Label id="Label3" runat="server" Width="368px"
> EnableViewState="False"></asp:Label></P>
> <P>
> <asp:Label id="Label8" runat="server" Width="115px"
> Height="19px">!IsPostBack:</asp:Label>
> <asp:PlaceHolder id="PlaceHolder4"
> runat="server"></asp:PlaceHolder>
> <asp:Label id="Label4" runat="server" Width="368px"
> EnableViewState="False"></asp:Label></P>
> </asp:panel>
> <P><asp:button id="Button1" runat="server" Text="Submit" Width="100px"
> Height="27px"></asp:button></P>
> <P><hr></P>
> <P>As you can see through experimenting with the above, the text<BR>
> box labeled "With ViewState" is the only one that works
properly.<BR>
> <BR>
> The "No ViewState" and the "Controls.AddAt" text boxes both<BR>
> fire their changed events whenever they contain text, even if
that<BR>
> text has not changed.<BR>
> <BR>
> The "!IsPostBack" text box simply disappears upon postback.</P>
> </form>
>
> **** CODE
> private void Page_Load(object sender, System.EventArgs e)
> {
> System.Web.UI.WebControls.TextBox MyTextBox;
> MyTextBox = new TextBox();
> MyTextBox.ID = "TextBox1";
> MyTextBox.EnableViewState=true;
> PlaceHolder1.Controls.Add(MyTextBox);
> MyTextBox.TextChanged += new
> System.EventHandler(this.TextBox_TextChanged);
> MyTextBox = new TextBox();
> MyTextBox.ID = "TextBox2";
> MyTextBox.EnableViewState=false;
> PlaceHolder2.Controls.Add(MyTextBox);
> MyTextBox.TextChanged += new
> System.EventHandler(this.TextBox_TextChanged);
> MyTextBox = new TextBox();
> MyTextBox.ID = "TextBox3";
> MyTextBox.EnableViewState=true;
> Panel1.Controls.AddAt(15,MyTextBox);
> MyTextBox.TextChanged += new
> System.EventHandler(this.TextBox_TextChanged);
> if(!IsPostBack)
> {
> MyTextBox = new TextBox();
> MyTextBox.ID = "TextBox4";
> MyTextBox.EnableViewState=true;
> PlaceHolder4.Controls.Add(MyTextBox);
> MyTextBox.TextChanged += new
> System.EventHandler(this.TextBox_TextChanged);
> }
> }
> private void TextBox_TextChanged(object sender, System.EventArgs e)
> {
> TextBox txtBoxSender = (TextBox)sender;
> string strTextBoxID = txtBoxSender.ID;
> switch(strTextBoxID)
> {
> case "TextBox1":
> Label1.Text = "Changed";
> break;
> case "TextBox2":
> Label2.Text = "Changed";
> break;
> case "TextBox3":
> Label3.Text = "Changed";
> break;
> case "TextBox4":
> Label4.Text = "Changed";
> break;
> }
> }
>
> --
> Please see these articles for more information.
> Adding Controls to a Web Forms Page Programmatically
http://msdn.microsoft.com/library/e...gcontrolstowebf
> ormspageprogrammatically.asp
> HOW TO: Dynamically Create Controls in ASP.NET by Using Visual C# .NET
> http://support.microsoft.com/defaul...kb;EN-US;317794
> Does this answer your question?
> Thank you, Mike
> Microsoft, ASP.NET Support Professional
> Microsoft highly recommends to all of our customers that they visit the
> http://www.microsoft.com/protect site and perform the three
straightforward
> steps listed to improve your computers security.
> This posting is provided "AS IS", with no warranties, and confers no
rights.
>
> -------
> > From: "Donald Xie" <donald_xie@dotnet.itags.org.msdn.nospam>
> > Subject: The Command event of dynamically loaded controls
> > Date: Fri, 30 Jan 2004 16:52:00 +0800
> > Lines: 54
> > X-Priority: 3
> > X-MSMail-Priority: Normal
> > X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
> > X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
> > Message-ID: <#C2U35w5DHA.2580@dotnet.itags.org.TK2MSFTNGP11.phx.gbl>
> > Newsgroups: microsoft.public.dotnet.framework.aspnet
> > NNTP-Posting-Host: 202.181.80.84
> > Path:
cpmsftngxa07.phx.gbl!cpmsftngxa10.phx.gbl!TK2MSFTN GXA05.phx.gbl!TK2MSFTNGP08
> phx.gbl!TK2MSFTNGP11.phx.gbl
> > Xref: cpmsftngxa07.phx.gbl
microsoft.public.dotnet.framework.aspnet:206364
> > X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
> > Hi,
> > I noticed an interesting effect when working with controls that are
> > dynamically loaded. For instance, on a web form with a PlaceHolder
control
> > named ImageHolder, I dynamically add an image button at runtime:
> > //-- Code snippet
> > protected System.Web.UI.WebControls.PlaceHolder ImageHolder;
> > private void Page_Load(object sender, System.EventArgs e)
> > {
> > if (!IsPostBack)
> > LoadDynamicImageButton();
> > }
> > private void ImageButton_Click(object sender,
> > System.Web.UI.ImageClickEventArgs e)
> > {
> > Response.Write("Image button clicked");
> > }
> > private void LoadDynamicImageButton()
> > {
> > ImageButton btn = new ImageButton();
> > btn.ImageUrl = "Images/Minus.png";
> > btn.Click += new ImageClickEventHandler(ImageButton_Click);
> > ImageHolder.Controls.Add(btn);
> > }
> > //-- End code snippet
> > The first time the page loads, the image button is created. When I click
> it,
> > it reloads the page but doesn't trigger its ImageClickEventHandler. If I
> > forcefully run LoadDynamicImageButton(), i.e., remove the IsPostBack
check
> > in Page_Load() to recreate the image, its ImageClickEventHandler is
> > triggered. This happens with the Command event as well.
> > It seems that on post-back, if a dynamically loaded control is not
loaded,
> > then its event handler is not wired. Its properties such as CommandName
> and
> > CommandArgument, OTOH, persists from the last load.
> > The problem is that if I dynamically load up the PlaceHolder control
with
> > different controls according to the button clicked, this behavior forces
> all
> > those controls to be loaded twice - first to load all default controls
> just
> > to wire up their event handlers, then to reload them again according to
> the
> > event. There are also other factors, such as the assigning a differnet
> > ImageUrl, that seem to affect whether or not the event handler is
> triggered.
> > I'm still working on it to hopefully isolate the problem.
> > Is there a workaround?
> > Thanks,
> > Donald Xie
Hi Donald,
Thank you for the response. Regarding on the issue, we are
finding proper resource to assist you and we will update as soon as posible.
Regards,
Steven Cheng
Microsoft Online Support
Get Secure! www.microsoft.com/security(This posting is provided "AS IS",
with no warranties, and confers no rights.)
Hi Donald,
As for the situation you mentioned in the last reply, here is my
suggestions on it:
1. If we manually build a "tree" programatically via a list of ImageButtons
or LinkButtons, I'm afraid there will cause some performance issues since
every time page loaded , it need to create and add these dynamic controls
so as to associate their states from viewstate, also register the event
handler for them. This will be a large challenge to the serverside.
2. Would you like to have a try on the TreeView control in the Microsoft
Internet Explorer WebControls? This treeview control has been added to the
MS's web control collections and have detailed reference and tutorial in
MSDN. Also, the IE webcontrols' source code is opened to public , you're
feel to extend their existed functions. Here is some tech references and
articls on the TreeView web control:
#TreeView WebControl Reference
http://msdn.microsoft.com/library/e...ingtreeviewiewe
bcontrol.asp?frame=true
And here is a test page I used to test dynamically add nodes when a certain
node is expanded. The treeview has
4 hierarchies and each contains 20 nodes. When a node is first time
expanded or selected, it dynamically add its child nodes. Please have a
look to see whether it possible for you to use this TreeView control.
In addition, if you have the "Application Center Test" installed, you may
try having a test on different approachs such as using TreeView or manually
add button lists so as to see the realtime performance. And here are
another two tech articles, one is about the MSDN site's TreeView 's
implementation in C#. I think they may be helpful to you,too.
#Hierarchical Data Binding in ASP.NET
http://msdn.microsoft.com/library/e...databinding.asp
?frame=true
#The MSDN Table of Contents in C#
http://msdn.microsoft.com/library/e...001.asp?frame=t
rue
Please check out the above suggestions. If you have any questions or if my
suggestions not quite suitable for your situation, please feel free to post
here.
Regards,
Steven Cheng
Microsoft Online Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Hi Donald,
Sorry for forgetting attach My test page's code in the last reply, here is
the Page code:
#If you haven't the IE web control's reference or code, you may get them at
http://www.asp.net/ControlGallery/C...l=75&tabindex=2
----------aspx page-----------
<%@dotnet.itags.org. Register TagPrefix="iewc" Namespace="Microsoft.Web.UI.WebControls"
Assembly="Microsoft.Web.UI.WebControls" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>DynaTree</title>
<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">
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<table width="500" align="center">
<tr>
<td><FONT face="">
<iewc:TreeView id="trvMain"
runat="server"></iewc:TreeView></FONT></td>
</tr>
<tr>
<td></td>
</tr>
</table>
</form>
</body>
</HTML
--------code behind class-----
public class DynaTree : System.Web.UI.Page
{
protected Microsoft.Web.UI.WebControls.TreeView trvMain;
private void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack)
{
LoadData();
BindTreeNodes(trvMain.Nodes,GetChildNodes("0"));
trvMain.AutoPostBack = true;
}
}
protected void LoadData()
{
DataTable tb = new DataTable();
tb.Columns.Add("nid");
tb.Columns.Add("pid");
tb.Columns.Add("name");
tb.Columns.Add("url");
tb.Columns.Add("target");
int i=0;
int j=0;
int k=0;
int l=0;
int nodeindex = 1;
for(i=1;i<=20;i++)
{
DataRow row1 = tb.NewRow();
row1["nid"] = i.ToString();
row1["pid"] = "0";
row1["name"] = "FirstLevelNode_"+nodeindex.ToString();
row1["url"] = "";
row1["target"] = "";
tb.Rows.Add(row1);
for(j=1;j<=20;j++)
{
DataRow row2 = tb.NewRow();
row2["nid"] = i.ToString() + j.ToString();
row2["pid"] = i.ToString();
row2["name"] = "SecondLevelNode_"+j.ToString();
row2["url"] = "";
row2["target"] = "";
tb.Rows.Add(row2);
for(k=1;k<=20;k++)
{
DataRow row3 = tb.NewRow();
row3["nid"] = i.ToString() + j.ToString() + k.ToString();
row3["pid"] = i.ToString() + j.ToString();
row3["name"] = "ThirdLevelNode_"+k.ToString();
row3["url"] = "";
row3["target"] = "";
tb.Rows.Add(row3);
for(l=1;l<20;l++)
{
DataRow row4 = tb.NewRow();
row4["nid"] = i.ToString() + j.ToString() + k.ToString() +
l.ToString();
row4["pid"] = i.ToString() + j.ToString() + k.ToString();
row4["name"] = "ForthLevelNode_"+k.ToString();
row4["url"] = "";
row4["target"] = "";
tb.Rows.Add(row4);
}
}
}
}
Session["TEMP_DATA"] = tb;
}
protected DataRow[] GetChildNodes(string pid)
{
DataTable tb = (DataTable)Session["TEMP_DATA"];
DataRow[] rows = tb.Select("pid = '" + pid +"'");
return rows;
}
protected void BindTreeNodes(TreeNodeCollection nodes, DataRow[] rows)
{
for(int i=0;i<rows.Length;i++)
{
TreeNode node = new TreeNode();
node.ID = rows[i]["nid"].ToString();
node.Text = rows[i]["name"].ToString();
node.NavigateUrl = rows[i]["url"].ToString();
node.Target = rows[i]["target"].ToString();
TreeNode emptynode = new TreeNode();
emptynode.ID = node.ID + "#$#EMPTY";
node.Nodes.Add(emptynode);
nodes.Add(node);
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
InitializeComponent();
base.OnInit(e);
}
private void InitializeComponent()
{
this.trvMain.Expand += new
Microsoft.Web.UI.WebControls.ClickEventHandler(thi s.trvMain_Expand);
this.trvMain.SelectedIndexChange += new
Microsoft.Web.UI.WebControls.SelectEventHandler(th is.trvMain_SelectedIndexCh
ange);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void trvMain_Expand(object sender,
Microsoft.Web.UI.WebControls.TreeViewClickEventArg s e)
{
TreeNode pnode = ((TreeView)sender).GetNodeFromIndex(e.Node);
TreeNode emptynode = pnode.Nodes[0];
if(emptynode.ID.IndexOf("#$#EMPTY") != -1)
{
pnode.Nodes.Clear();
BindTreeNodes(pnode.Nodes,GetChildNodes(pnode.ID)) ;
}
}
private void trvMain_SelectedIndexChange(object sender,
Microsoft.Web.UI.WebControls.TreeViewSelectEventAr gs e)
{
TreeNode oldnode = ((TreeView)sender).GetNodeFromIndex(e.OldNode);
TreeNode newnode = ((TreeView)sender).GetNodeFromIndex(e.NewNode);
if(newnode.Nodes.Count>0)
{
TreeNode emptynode = newnode.Nodes[0];
if(emptynode.ID.IndexOf("#$#EMPTY") != -1)
{
newnode.Nodes.Clear();
BindTreeNodes(newnode.Nodes,GetChildNodes(newnode. ID));
}
}
}
}
Hi Steven,
Thanks so much for your suggestions and the sample code - they are exactly
the information I need.
The TreeView control is the more conventional, and the MSDN TOC in C# is
very elegant and certainly well proven. I will go through both to see which
is the best for this application.
The hierarchical data binding approach is in essense what I'm doing
manually, as the depth of each node is variable. However I suspect that it
also suffers the same render-twice problem if we want to do more than just
displaying the nodes and get their state on post back.
Best,
Donald Xie
"Steven Cheng[MSFT]" <v-schang@dotnet.itags.org.online.microsoft.com> wrote in message
news:8JbKxSx6DHA.3524@dotnet.itags.org.cpmsftngxa07.phx.gbl...
> Hi Donald,
>
> As for the situation you mentioned in the last reply, here is my
> suggestions on it:
> 1. If we manually build a "tree" programatically via a list of
ImageButtons
> or LinkButtons, I'm afraid there will cause some performance issues since
> every time page loaded , it need to create and add these dynamic controls
> so as to associate their states from viewstate, also register the event
> handler for them. This will be a large challenge to the serverside.
> 2. Would you like to have a try on the TreeView control in the Microsoft
> Internet Explorer WebControls? This treeview control has been added to the
> MS's web control collections and have detailed reference and tutorial in
> MSDN. Also, the IE webcontrols' source code is opened to public , you're
> feel to extend their existed functions. Here is some tech references and
> articls on the TreeView web control:
> #TreeView WebControl Reference
http://msdn.microsoft.com/library/e...ingtreeviewiewe
> bcontrol.asp?frame=true
> And here is a test page I used to test dynamically add nodes when a
certain
> node is expanded. The treeview has
> 4 hierarchies and each contains 20 nodes. When a node is first time
> expanded or selected, it dynamically add its child nodes. Please have a
> look to see whether it possible for you to use this TreeView control.
> In addition, if you have the "Application Center Test" installed, you may
> try having a test on different approachs such as using TreeView or
manually
> add button lists so as to see the realtime performance. And here are
> another two tech articles, one is about the MSDN site's TreeView 's
> implementation in C#. I think they may be helpful to you,too.
> #Hierarchical Data Binding in ASP.NET
http://msdn.microsoft.com/library/e...databinding.asp
> ?frame=true
> #The MSDN Table of Contents in C#
http://msdn.microsoft.com/library/e...001.asp?frame=t
> rue
>
> Please check out the above suggestions. If you have any questions or if my
> suggestions not quite suitable for your situation, please feel free to
post
> here.
>
> Regards,
> Steven Cheng
> Microsoft Online Support
> Get Secure! www.microsoft.com/security
> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)
Hi Donald,
Thanks for your response. I'm glad that my suggestions are helpful to you.
As for the things I mentioned in the last reply, here some of my further
suggestions:
As for the "MSDN TOC in C#", since it is not provided as a Web Server
Control and the DataSource is based on serveral xml files. If you'd like to
use this means, I think you may try dynamically generic the certain XML
files from your own datasource. That'll save your times.
Anyway, which approach to choose all depends on the real time performance.
Hope you'll soon figure out the most appropriate means.
Regards,
Steven Cheng
Microsoft Online Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Thursday, March 22, 2012
The file could not be loaded into the Web Forms designer
install. I am unable to use the web forms designer with any aspx file
whose
form class inherits from a base class. I'm implementing the page
controller
design pattern and everything has been working fine until now. My form
inherits from a base class called CampusNET.CampusPage. The class
exists, is
included in the project and compiles just fine. If I replace the base
class
for my form with the standard System.Web.UI.Page, the designer can open
the
form without any problems, but as soon as I try to inherit from my base
class, it breaks down. I've tried it with an empty base class with only
the
Page_Load method, but the problem remains.
The base class is not abstract so that's not the issue. Neither is the
problem related to the registry entry that leads to the "Illegal
character
in path" error. The full error message looks like this:
"The file could not be loaded into the Web Forms designer. Please
correct
the following error and then try loading it again:
The designer could not be shown for this file because none of the
classes
within can be designed. The designer inspected the following classes in
the
file:
MenuTest -- The base class 'CampusNET.CampusPage' could not be loaded.
Ensure the assembly has been referenced or built if it is part of the
project.
Make sure all of the classes used in the page are build or referenced
in the
project. Click Help for more information."
Has anyone encountered this problem before? I really need to get this
fixed
as soon as possible.
Regards
/CThis is a known issue. I'm pretty certain that it's fixed in VS2005.
I've had something similar with my own base classes... probably a simpler
situation than yours. Mine rears it's head the first time you get the source
code from source control, before you build your project. My project also
contains the base class. It seems as if the designer needs the compiled
version of the base class present - so my fix is to build the project so the
base class gets fixed and all seems to work OK
Hope this helps
Richard MCSD .NET
"crusell@.gmail.com" wrote:
> I'm having some problem with my Visual Studio.NET 2003 (.NET 1.1 SP1)
> install. I am unable to use the web forms designer with any aspx file
> whose
> form class inherits from a base class. I'm implementing the page
> controller
> design pattern and everything has been working fine until now. My form
> inherits from a base class called CampusNET.CampusPage. The class
> exists, is
> included in the project and compiles just fine. If I replace the base
> class
> for my form with the standard System.Web.UI.Page, the designer can open
> the
> form without any problems, but as soon as I try to inherit from my base
> class, it breaks down. I've tried it with an empty base class with only
> the
> Page_Load method, but the problem remains.
> The base class is not abstract so that's not the issue. Neither is the
> problem related to the registry entry that leads to the "Illegal
> character
> in path" error. The full error message looks like this:
> "The file could not be loaded into the Web Forms designer. Please
> correct
> the following error and then try loading it again:
> The designer could not be shown for this file because none of the
> classes
> within can be designed. The designer inspected the following classes in
> the
> file:
> MenuTest -- The base class 'CampusNET.CampusPage' could not be loaded.
> Ensure the assembly has been referenced or built if it is part of the
> project.
> Make sure all of the classes used in the page are build or referenced
> in the
> project. Click Help for more information."
> Has anyone encountered this problem before? I really need to get this
> fixed
> as soon as possible.
> Regards
> /C
>
The file could not be loaded into the Web Forms designer
install. I am unable to use the web forms designer with any aspx file
whose
form class inherits from a base class. I'm implementing the page
controller
design pattern and everything has been working fine until now. My form
inherits from a base class called CampusNET.CampusPage. The class
exists, is
included in the project and compiles just fine. If I replace the base
class
for my form with the standard System.Web.UI.Page, the designer can open
the
form without any problems, but as soon as I try to inherit from my base
class, it breaks down. I've tried it with an empty base class with only
the
Page_Load method, but the problem remains.
The base class is not abstract so that's not the issue. Neither is the
problem related to the registry entry that leads to the "Illegal
character
in path" error. The full error message looks like this:
"The file could not be loaded into the Web Forms designer. Please
correct
the following error and then try loading it again:
The designer could not be shown for this file because none of the
classes
within can be designed. The designer inspected the following classes in
the
file:
MenuTest -- The base class 'CampusNET.CampusPage' could not be loaded.
Ensure the assembly has been referenced or built if it is part of the
project.
Make sure all of the classes used in the page are build or referenced
in the
project. Click Help for more information."
Has anyone encountered this problem before? I really need to get this
fixed
as soon as possible.
Regards
/CThis is a known issue. I'm pretty certain that it's fixed in VS2005.
I've had something similar with my own base classes... probably a simpler
situation than yours. Mine rears it's head the first time you get the sourc
e
code from source control, before you build your project. My project also
contains the base class. It seems as if the designer needs the compiled
version of the base class present - so my fix is to build the project so the
base class gets fixed and all seems to work OK
Hope this helps
Richard MCSD .NET
"crusell@.gmail.com" wrote:
> I'm having some problem with my Visual Studio.NET 2003 (.NET 1.1 SP1)
> install. I am unable to use the web forms designer with any aspx file
> whose
> form class inherits from a base class. I'm implementing the page
> controller
> design pattern and everything has been working fine until now. My form
> inherits from a base class called CampusNET.CampusPage. The class
> exists, is
> included in the project and compiles just fine. If I replace the base
> class
> for my form with the standard System.Web.UI.Page, the designer can open
> the
> form without any problems, but as soon as I try to inherit from my base
> class, it breaks down. I've tried it with an empty base class with only
> the
> Page_Load method, but the problem remains.
> The base class is not abstract so that's not the issue. Neither is the
> problem related to the registry entry that leads to the "Illegal
> character
> in path" error. The full error message looks like this:
> "The file could not be loaded into the Web Forms designer. Please
> correct
> the following error and then try loading it again:
> The designer could not be shown for this file because none of the
> classes
> within can be designed. The designer inspected the following classes in
> the
> file:
> MenuTest -- The base class 'CampusNET.CampusPage' could not be loaded.
> Ensure the assembly has been referenced or built if it is part of the
> project.
> Make sure all of the classes used in the page are build or referenced
> in the
> project. Click Help for more information."
> Has anyone encountered this problem before? I really need to get this
> fixed
> as soon as possible.
> Regards
> /C
>