Is there a way to dynamically add in User Controls where I would get the
name from a session variable:
If I have the following code:
*************** *************** *************** *************** *************** ***
<%@ Page Language="VB" trace="false" debug="true" ContentType="te xt/html"
ResponseEncodin g="iso-8859-1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@ Register TagPrefix="fts" TagName="Naviga te" Src="sdhcNaviga te.ascx" %>
<%@ Register TagPrefix="fts" TagName="Naviga te" Src="ft2Navigat e.ascx" %>
<%@ Register TagPrefix="fts" TagName="Naviga te" Src="sbNavigate .ascx" %>
<html>
<head>
<title>:: Staffing Workshop ::</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<body id="myBody" runat="server">
<form id="addForm" runat="server">
<fts:Navigate runat="Server"/>
</form>
</body>
</html>
*************** *************** *************** *************** *************** *****
I would like to change it so that I can do something like changing the Src
attribute of the Register statement based on a session variable.
For example if my session variable "company" was either "sdhcNavigate.a scx",
"ft2Navigate.as cx" or "sbNavigate.asc x"
*************** *************** *************** *************** *************** ***
<%@ Page Language="VB" trace="false" debug="true" ContentType="te xt/html"
ResponseEncodin g="iso-8859-1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@ Register TagPrefix="fts" TagName="Naviga te" Src="" %>
<script runat="server">
Sub Page_Load(sende r as Object, e as EventArgs)
if not IsPostBack
Set the Src of the control here (or maybe in the html area)
end if
</script
<html>
<head>
<title>:: Staffing Workshop ::</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<body id="myBody" runat="server">
<form id="addForm" runat="server">
<fts:Navigate runat="Server"/>
</form>
</body>
</html>
*************** *************** *************** *************** *************** *****
I would use this in all my 50 pages to load the control based on the
company.
Thanks,
Tom 2 1177
Hi,
The way I do this:
Don't put any register tag prefixes.
Put a placeholder where you want the control to appear.
In your code behind load the control you want, i.e.:
Dim MyControl As New Control
MyControl = LoadControl("Tr avelClinicSearc h.ascx")
plcDatabases.Co ntrols.Add(MyCo ntrol)
Where plcDatabases is the name of the placeholder. Obviously, the
control name can be a variable.
Hope this helps.
Gareth
tshad wrote:
Is there a way to dynamically add in User Controls where I would get the
name from a session variable:
If I have the following code:
*************** *************** *************** *************** *************** ***
<%@ Page Language="VB" trace="false" debug="true" ContentType="te xt/html"
ResponseEncodin g="iso-8859-1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@ Register TagPrefix="fts" TagName="Naviga te" Src="sdhcNaviga te.ascx" %>
<%@ Register TagPrefix="fts" TagName="Naviga te" Src="ft2Navigat e.ascx" %>
<%@ Register TagPrefix="fts" TagName="Naviga te" Src="sbNavigate .ascx" %>
<html>
<head>
<title>:: Staffing Workshop ::</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<body id="myBody" runat="server">
<form id="addForm" runat="server">
<fts:Navigate runat="Server"/>
</form>
</body>
</html>
*************** *************** *************** *************** *************** *****
I would like to change it so that I can do something like changing the Src
attribute of the Register statement based on a session variable.
For example if my session variable "company" was either "sdhcNavigate.a scx",
"ft2Navigate.as cx" or "sbNavigate.asc x"
*************** *************** *************** *************** *************** ***
<%@ Page Language="VB" trace="false" debug="true" ContentType="te xt/html"
ResponseEncodin g="iso-8859-1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@ Register TagPrefix="fts" TagName="Naviga te" Src="" %>
<script runat="server">
Sub Page_Load(sende r as Object, e as EventArgs)
if not IsPostBack
Set the Src of the control here (or maybe in the html area)
end if
</script
<html>
<head>
<title>:: Staffing Workshop ::</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<body id="myBody" runat="server">
<form id="addForm" runat="server">
<fts:Navigate runat="Server"/>
</form>
</body>
</html>
*************** *************** *************** *************** *************** *****
I would use this in all my 50 pages to load the control based on the
company.
Thanks,
Tom
That was what I was looking for.
I wanted to be able to load a control depending on settings in my session
variables and this would allow me to do that.
Thanks,
Tom
"gareth" <ga************ ****@gmail.comw rote in message
news:11******** *************@i 3g2000cwc.googl egroups.com...
Hi,
The way I do this:
Don't put any register tag prefixes.
Put a placeholder where you want the control to appear.
In your code behind load the control you want, i.e.:
Dim MyControl As New Control
MyControl = LoadControl("Tr avelClinicSearc h.ascx")
plcDatabases.Co ntrols.Add(MyCo ntrol)
Where plcDatabases is the name of the placeholder. Obviously, the
control name can be a variable.
Hope this helps.
Gareth
tshad wrote:
>Is there a way to dynamically add in User Controls where I would get the name from a session variable:
If I have the following code: ************** *************** *************** *************** *************** **** <%@ Page Language="VB" trace="false" debug="true" ContentType="te xt/html" ResponseEncodi ng="iso-8859-1" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ Register TagPrefix="fts" TagName="Naviga te" Src="sdhcNaviga te.ascx" %> <%@ Register TagPrefix="fts" TagName="Naviga te" Src="ft2Navigat e.ascx" %> <%@ Register TagPrefix="fts" TagName="Naviga te" Src="sbNavigate .ascx" %>
<html> <head> <title>:: Staffing Workshop ::</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <body id="myBody" runat="server"> <form id="addForm" runat="server">
<fts:Navigate runat="Server"/>
</form> </body> </html> ************** *************** *************** *************** *************** ******
I would like to change it so that I can do something like changing the Src attribute of the Register statement based on a session variable.
For example if my session variable "company" was either "sdhcNavigate. ascx", "ft2Navigate.a scx" or "sbNavigate.asc x"
************** *************** *************** *************** *************** **** <%@ Page Language="VB" trace="false" debug="true" ContentType="te xt/html" ResponseEncodi ng="iso-8859-1" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ Register TagPrefix="fts" TagName="Naviga te" Src="" %> <script runat="server"> Sub Page_Load(sende r as Object, e as EventArgs) if not IsPostBack
Set the Src of the control here (or maybe in the html area)
end if </script <html> <head> <title>:: Staffing Workshop ::</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <body id="myBody" runat="server"> <form id="addForm" runat="server">
<fts:Navigate runat="Server"/>
</form> </body> </html> ************** *************** *************** *************** *************** ******
I would use this in all my 50 pages to load the control based on the company.
Thanks,
Tom
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: sameer mowade via .NET 247 |
last post by:
Hello All,
I have problem while dynamically removing row from the Datagrid which i have added dynamically as shown in the following code snippet. The problem is that while removing dynamically added row it also removes the row at the end along with the added row.
Plz tell me if, I am missing any thing.
Code
</asp:datagrid>
|
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: Steve Booth |
last post by:
I have a web form with a button and a placeholder, the button adds a user
control to the placeholder (and removes any existing controls). The user
control contains a single button. I have done all the usual stuff of
recreating the usercontrol in the Page Init event.
The 'failure' sequence is as follows:
- select web form button to display the user control
- select user control button, event fires
- select web form button to display...
|
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: |
last post by:
I have made some user controls with custom properties. I can set those
properties on instances of my user controls, and I have programmed my user
control to do useful visual things in response to how those properties are
set.
I want to be able to do two other things:
a) add User control instances to my page, filling in the place of
placeholder controls, and
b) programmatically setting custom properties on those dynamically spawned...
| |
by: Chris |
last post by:
I am dynamically adding a user control to each row in a gridview. The reason
I am doing it dynamically is the user control is different depending on
certain data in the gridview. The gridview contains a placeholder and I add
the control to it, the user control is a formview bound to an object
datsource. This works great until I post back the page and the user control
disappears. What am I doing wrong? Regards, Chris.
Protected Sub...
|
by: jelle.huygen |
last post by:
Hello,
I have a problem in ASP.NET 2.0 with the viewstate of my dynamically
added user control. I have reproduced the problem with a very simple
user control and a very simple page.
On my usercontrol is a button and a label. Everytime the button is
clicked a counter which is stored in the viewstate is increased and
displayed in the label.
|
by: Shraddha |
last post by:
Hi,
I am adding some ASP.Net user controls (.ascx file) dynamically on the
button click. The user control will get added as many times userhits
the button. Now on the click of the submit button, I want to do some
form level validations.
For example suppose my .ascx file contains a text box with id say
"trialTextBox".
Now if user hits the button thrice, 3 user controls will be there on
the page and as a result 3 textboxes mentioned...
|
by: Lewis Holmes |
last post by:
Hi
I have the following situation in one of my asp.net pages.
The user can add multiple table rows to a form by selecting a button. These
rows can contain asp.net controls. When this button is selected, the row is
added using JavaScript. The script uses cloneNode to clone a hidden template
row and all of its children and then adds the new row to the table, updates
all of the child control Ids and sets visibility etc.
The hidden...
|
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: 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: 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: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |