Hello EveryBody,
I have a dropdownlist with some values as .net server controls & a button ,
on clicking a button i need to generate the choosen contorl dynamically.
I am giving a small glimpse of my code for your understanding
the aspx page has dropdwon list with values as below.
<asp:DropDownLi st id="DropDownLis t1" runat="server">
<asp:ListItem Value="Label">L abel</asp:ListItem>
<asp:ListItem Value="DropDown List">DropDownL ist</asp:ListItem>
<asp:ListItem Value="DataGrid ">DataGrid</asp:ListItem>
<asp:ListItem Value="DataList ">DataList</asp:ListItem>
<asp:ListItem Value="CheckBox ">CheckBox</asp:ListItem>
<asp:ListItem Value="RadioBut ton">RadioButto n</asp:ListItem>
<asp:ListItem Value="RadioBut ton">RadioButto n</asp:ListItem>
<asp:ListItem Value="Table">T able</asp:ListItem>
<asp:ListItem Value="TextBox" >TextBox</asp:ListItem>
<asp:ListItem ></asp:ListItem>
</asp:DropDownLis t>
now the code that gets executed at the click of the button is as follows
i am using the reflection name space
String strCtrlName = DropDownList1.S electedItem.Val ue ;
Response.Write( strCtrlName);
Type tp=System.Type. GetType("System .Web.UI.WebCont rols."+strCtrlN ame ,true) ;
Object obj = Activator.Creat eInstance(tp0;
PlaceHolder.Con trols.Add(new obj );
but i get error at the line " Type
tp=System.Type. GetType("System .Web.UI.WebCont rols."+strCtrlN ame ,true) ; "
error below :
System.SystemEx ception: {"Could not load type
System.Web.UI.W ebControls.Data Grid from assembly TestingDynamicC trl,
Version=1.0.195 0.28617, Culture=neutral , PublicKeyToken= null."}
AssemblyName: "TestingDynamic Ctrl, Version=1.0.195 0.28617, Culture=neutral ,
PublicKeyToken= null"
ClassName: "System.Web.UI. WebControls.Dat aGrid"
Message: "Could not load type System.Web.UI.W ebControls.Data Grid from
assembly TestingDynamicC trl, Version=1.0.195 0.28617, Culture=neutral ,
PublicKeyToken= null."
MessageArg: null
ResourceId: -2146233054
TypeName: "System.Web.UI. WebControls.Dat aGrid"
so could you pls help me out with your expert advices on solving the problem
and generating the control dynamically.
your expert advice would be highly appreciated.
Rgds
Shiju 4 1678
When getting the type of a class, you need to specify the assembly, ala:
"System.Web.UI. WebControls.Dro pDownList, System.Web"
Since the "System.Web " assembly is in the GAC, you must also specify the
version, publickeytoken and culture, ala:
"System.Web.UI. WebControls.Lab el, System.Web, Version=1.0.500 0.0,
Culture=neutral , PublicKeyToken= b03f5f7f11d50a3 a"
You can get the information by checking out c:\windows\asse mbly though
it'll be the same for you..
Karl
--
MY ASP.Net tutorials http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying) http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Shiju Poyilil" <Sh**********@d iscussions.micr osoft.com> wrote in message
news:0B******** *************** ***********@mic rosoft.com... Hello EveryBody, I have a dropdownlist with some values as .net server controls & a button , on clicking a button i need to generate the choosen contorl dynamically.
I am giving a small glimpse of my code for your understanding the aspx page has dropdwon list with values as below.
<asp:DropDownLi st id="DropDownLis t1" runat="server"> <asp:ListItem Value="Label">L abel</asp:ListItem> <asp:ListItem Value="DropDown List">DropDownL ist</asp:ListItem> <asp:ListItem Value="DataGrid ">DataGrid</asp:ListItem> <asp:ListItem Value="DataList ">DataList</asp:ListItem> <asp:ListItem Value="CheckBox ">CheckBox</asp:ListItem> <asp:ListItem Value="RadioBut ton">RadioButto n</asp:ListItem> <asp:ListItem Value="RadioBut ton">RadioButto n</asp:ListItem> <asp:ListItem Value="Table">T able</asp:ListItem> <asp:ListItem Value="TextBox" >TextBox</asp:ListItem> <asp:ListItem ></asp:ListItem> </asp:DropDownLis t>
now the code that gets executed at the click of the button is as follows
i am using the reflection name space
String strCtrlName = DropDownList1.S electedItem.Val ue ; Response.Write( strCtrlName);
Type tp=System.Type. GetType("System .Web.UI.WebCont rols."+strCtrlN ame ,true) ; Object obj = Activator.Creat eInstance(tp0; PlaceHolder.Con trols.Add(new obj );
but i get error at the line " Type tp=System.Type. GetType("System .Web.UI.WebCont rols."+strCtrlN ame ,true) ; "
error below :
System.SystemEx ception: {"Could not load type System.Web.UI.W ebControls.Data Grid from assembly TestingDynamicC trl, Version=1.0.195 0.28617, Culture=neutral , PublicKeyToken= null."} AssemblyName: "TestingDynamic Ctrl, Version=1.0.195 0.28617, Culture=neutral , PublicKeyToken= null" ClassName: "System.Web.UI. WebControls.Dat aGrid" Message: "Could not load type System.Web.UI.W ebControls.Data Grid from assembly TestingDynamicC trl, Version=1.0.195 0.28617, Culture=neutral , PublicKeyToken= null." MessageArg: null ResourceId: -2146233054 TypeName: "System.Web.UI. WebControls.Dat aGrid"
so could you pls help me out with your expert advices on solving the problem and generating the control dynamically.
your expert advice would be highly appreciated.
Rgds Shiju
"Shiju Poyilil" <Sh**********@d iscussions.micr osoft.com> wrote in message
news:0B******** *************** ***********@mic rosoft.com... Hello EveryBody, I have a dropdownlist with some values as .net server controls & a button , on clicking a button i need to generate the choosen contorl dynamically.
I am giving a small glimpse of my code for your understanding the aspx page has dropdwon list with values as below.
<asp:DropDownLi st id="DropDownLis t1" runat="server"> <asp:ListItem Value="Label">L abel</asp:ListItem> <asp:ListItem Value="DropDown List">DropDownL ist</asp:ListItem> <asp:ListItem Value="DataGrid ">DataGrid</asp:ListItem> <asp:ListItem Value="DataList ">DataList</asp:ListItem> <asp:ListItem Value="CheckBox ">CheckBox</asp:ListItem> <asp:ListItem Value="RadioBut ton">RadioButto n</asp:ListItem> <asp:ListItem Value="RadioBut ton">RadioButto n</asp:ListItem> <asp:ListItem Value="Table">T able</asp:ListItem> <asp:ListItem Value="TextBox" >TextBox</asp:ListItem> <asp:ListItem ></asp:ListItem> </asp:DropDownLis t>
now the code that gets executed at the click of the button is as follows
i am using the reflection name space
String strCtrlName = DropDownList1.S electedItem.Val ue ; Response.Write( strCtrlName);
Type tp=System.Type. GetType("System .Web.UI.WebCont rols."+strCtrlN ame ,true) ; Object obj = Activator.Creat eInstance(tp0; PlaceHolder.Con trols.Add(new obj );
but i get error at the line " Type tp=System.Type. GetType("System .Web.UI.WebCont rols."+strCtrlN ame ,true) ; "
Try adding the full assembly name to the string.
"System.Web.UI. WebControls.Tex tBox, System.Web, Version=1.0.500 0.0,
Culture=neutral , PublicKeyToken= b03f5f7f11d50a3 a"
You can use
TextBox tb = new TextBox();
string tmp = tb.GetType().As semblyQualified Name;
to find out what it is.
Peter
Thanks Peter for the help
"Peter Laan" wrote: "Shiju Poyilil" <Sh**********@d iscussions.micr osoft.com> wrote in message news:0B******** *************** ***********@mic rosoft.com... Hello EveryBody, I have a dropdownlist with some values as .net server controls & a button , on clicking a button i need to generate the choosen contorl dynamically.
I am giving a small glimpse of my code for your understanding the aspx page has dropdwon list with values as below.
<asp:DropDownLi st id="DropDownLis t1" runat="server"> <asp:ListItem Value="Label">L abel</asp:ListItem> <asp:ListItem Value="DropDown List">DropDownL ist</asp:ListItem> <asp:ListItem Value="DataGrid ">DataGrid</asp:ListItem> <asp:ListItem Value="DataList ">DataList</asp:ListItem> <asp:ListItem Value="CheckBox ">CheckBox</asp:ListItem> <asp:ListItem Value="RadioBut ton">RadioButto n</asp:ListItem> <asp:ListItem Value="RadioBut ton">RadioButto n</asp:ListItem> <asp:ListItem Value="Table">T able</asp:ListItem> <asp:ListItem Value="TextBox" >TextBox</asp:ListItem> <asp:ListItem ></asp:ListItem> </asp:DropDownLis t>
now the code that gets executed at the click of the button is as follows
i am using the reflection name space
String strCtrlName = DropDownList1.S electedItem.Val ue ; Response.Write( strCtrlName);
Type tp=System.Type. GetType("System .Web.UI.WebCont rols."+strCtrlN ame ,true) ; Object obj = Activator.Creat eInstance(tp0; PlaceHolder.Con trols.Add(new obj );
but i get error at the line " Type tp=System.Type. GetType("System .Web.UI.WebCont rols."+strCtrlN ame ,true) ; "
Try adding the full assembly name to the string. "System.Web.UI. WebControls.Tex tBox, System.Web, Version=1.0.500 0.0, Culture=neutral , PublicKeyToken= b03f5f7f11d50a3 a"
You can use
TextBox tb = new TextBox();
string tmp = tb.GetType().As semblyQualified Name;
to find out what it is. Peter
Thanks Karl for the speedy reply, it worked for me.
Rgds
Shiju
"Karl Seguin" wrote: When getting the type of a class, you need to specify the assembly, ala:
"System.Web.UI. WebControls.Dro pDownList, System.Web"
Since the "System.Web " assembly is in the GAC, you must also specify the version, publickeytoken and culture, ala:
"System.Web.UI. WebControls.Lab el, System.Web, Version=1.0.500 0.0, Culture=neutral , PublicKeyToken= b03f5f7f11d50a3 a"
You can get the information by checking out c:\windows\asse mbly though it'll be the same for you..
Karl
-- MY ASP.Net tutorials http://www.openmymind.net/ - New and Improved (yes, the popup is annoying) http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to come!) "Shiju Poyilil" <Sh**********@d iscussions.micr osoft.com> wrote in message news:0B******** *************** ***********@mic rosoft.com... Hello EveryBody, I have a dropdownlist with some values as .net server controls & a button , on clicking a button i need to generate the choosen contorl dynamically.
I am giving a small glimpse of my code for your understanding the aspx page has dropdwon list with values as below.
<asp:DropDownLi st id="DropDownLis t1" runat="server"> <asp:ListItem Value="Label">L abel</asp:ListItem> <asp:ListItem Value="DropDown List">DropDownL ist</asp:ListItem> <asp:ListItem Value="DataGrid ">DataGrid</asp:ListItem> <asp:ListItem Value="DataList ">DataList</asp:ListItem> <asp:ListItem Value="CheckBox ">CheckBox</asp:ListItem> <asp:ListItem Value="RadioBut ton">RadioButto n</asp:ListItem> <asp:ListItem Value="RadioBut ton">RadioButto n</asp:ListItem> <asp:ListItem Value="Table">T able</asp:ListItem> <asp:ListItem Value="TextBox" >TextBox</asp:ListItem> <asp:ListItem ></asp:ListItem> </asp:DropDownLis t>
now the code that gets executed at the click of the button is as follows
i am using the reflection name space
String strCtrlName = DropDownList1.S electedItem.Val ue ; Response.Write( strCtrlName);
Type tp=System.Type. GetType("System .Web.UI.WebCont rols."+strCtrlN ame ,true) ; Object obj = Activator.Creat eInstance(tp0; PlaceHolder.Con trols.Add(new obj );
but i get error at the line " Type tp=System.Type. GetType("System .Web.UI.WebCont rols."+strCtrlN ame ,true) ; "
error below :
System.SystemEx ception: {"Could not load type System.Web.UI.W ebControls.Data Grid from assembly TestingDynamicC trl, Version=1.0.195 0.28617, Culture=neutral , PublicKeyToken= null."} AssemblyName: "TestingDynamic Ctrl, Version=1.0.195 0.28617, Culture=neutral , PublicKeyToken= null" ClassName: "System.Web.UI. WebControls.Dat aGrid" Message: "Could not load type System.Web.UI.W ebControls.Data Grid from assembly TestingDynamicC trl, Version=1.0.195 0.28617, Culture=neutral , PublicKeyToken= null." MessageArg: null ResourceId: -2146233054 TypeName: "System.Web.UI. WebControls.Dat aGrid"
so could you pls help me out with your expert advices on solving the problem and generating the control dynamically.
your expert advice would be highly appreciated.
Rgds Shiju This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Bas Groeneveld |
last post by:
I am developing an ASP.NET application part of which consists of a data
entry wizard defined by entries in a data table - ie the controls on each
page of the wizard are determined by definitions in the table.
I know that I can dynamically add controls (eg a textbox) to the page
controls collection of a web form in a server event which will then be
rendered onto the form, as in the following snippet:
System.Web.UI.WebControls.TextBox...
|
by: Kamal Jeet Singh |
last post by:
Hi Friends !!
I am facing problem in controlling the dynamically created
controls on web page. The problem Scenario is
Scenario:- My requirement is to load the web user controls on the web
page dynamically. To do this, First I including a web page
(MainPage.aspx) and I made form tag to Runat=Server. I included one
table tag and also made this table Runat=Server side. Second I created
three Web User Controls e.g. wucCustomerInfo.ascx,
|
by: Patrick |
last post by:
I want to define a set of web-form templates in XML and render the equivalent
web-form with ASP.NET, then process any input server controls on the form.
Reading the XML file from Page_load is easy, but
1) How do I set about dynamically creating user controls (like TextBox,
TextArea)
--- simply Declare and initialised (new) the user controls?? How do I
"place" it graphically on the form. Ideally, I want them to lay out in a
table, one...
|
by: Dotnet Gruven |
last post by:
I've built a WebForm with a Table added dynamically in Page_Load when
IsPostBack is false. The table includes a couple of TextBoxes,
RadioButtonLists and CheckboxLists.
On postback, those controls are not present nor their valves in
Request.Form.AllKeys.
|
by: netasp |
last post by:
hi all,
how can I populate one aspx form when page is loading based on page ID? for
example:
loading page A (to search for VB code) would display labels and texboxes,
dropdown lists all related to VB, plus the address bar would show something
like this: www.somethinghere?id=3
and if you change number 3 from the address bar to (for example) 34 or 71
you would get different page with the same formatting like I.e:
www.somethinghere?id=34...
| |
by: Bjorn Sagbakken |
last post by:
Hello
In VS2005:
I am adding buttons and textboxes dynamically into a table, that also
dynamically expands.
So far, so good, actually very nice.
But I am having trouble starting the desired subroutine on postback. To me
it seems like the button click event looks for a client script instead of
going to the aspx codepage and execute the sub there.
The same thing happens with textboxes, where I programatically add
|
by: Nathan Sokalski |
last post by:
I have a custom control that I wrote (I inherit from
System.Web.UI.WebControls.CompositeControl). I dynamically add this control
to my Page, but I was told that dynamically added controls do not survive
postback. This seems to be true. However, this seems to make dynamically
adding controls rather pointless to me, since if you cannot retrieve the
values of the controls when you perform a postback, why add the controls in
the firstplace?...
|
by: mohaaron |
last post by:
I can think of a lot of reasons why this might need to be done but as
far as I can tell it's not possible. I've been looking for a way to
add HtmlTableRows to a table using a button click for a while and it
seems it's not possible because the row that gets added with each
click won't get recreated after a post back. After all the reading it
seems that any dynamically created controls must be created in the
Init event to be recreated after...
|
by: BillE |
last post by:
When I create a control dynamically and it grows according to the content,
the control Height property still returns the original default control
height instead of the height after expanding.
How can I get the height of the control (in code) after it grows?
I am building a windows form dynamically, creating controls and placing them
on the form. There can be dozens of controls of all types on the form.
This is for dynamic...
|
by: semomaniz |
last post by:
I have a form where i have created the form dynamically. First i manually added a panel control to the web page. Then i added another panel dynamically and inside this panel i created tables. I have set text boxes and labels inside the table rows. I then added a button. All of these are done through code.
The problem that i am having is i can get the value from a text box with resides inside the first panel (out side of panel that is...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |