Controlling ascx page in aspx page

Hi all,

Im totally new in asp.net and i have a few questions.
I have several page's and on each page i use a header.ascx to display the header on each aspx page.
How can i control for example a label (lblCustom.text, lblCustom.visible) wich is placed in my ascx file with code in my aspx page ??
My second question??
I want to email some information to several people in my web application.
The problem is the content of the email is not displayed very nice, for example
username:.......test
password: ...................abcdfdf
Address: .....teststreet
(the dots are spaces)
how can I manage that everything is displayed nice for example:
username:......... test
password:......... abcdfdf
Address:........... teststreet
Thanks in Advance,
Oss
0
Oss_Newbie
11/13/2004 2:40:18 PM
asp.net.getting-started 91979 articles. 4 followers. Follow

8 Replies
886 Views

Similar Articles

[PageSpeed] 19

an ascx file is considered a control. 

controls are manipulated via their properties.
so,
add public properties to the control that the page can manipulate to set internal vars inside the control. the control reads its internal vars to perform its rendering.
Mike Banavige
~~~~~~~~~~~~

Need a site code sample in a different language? Try converting it with: http://converter.telerik.com/
0
mbanavige
11/13/2004 2:56:46 PM
Hi Oss,

For you to be able to manipulate a child control inside a user control, you should declared it public. And in your web forms code behind, declare the user control as
protected WebUserControl1 uc1;
then you can access the label control as
uc1.lblCustom.Text
One thing to remember is, the identifier of the user control (uc1 in this case) should be the same as the id of this user control in the html tag. Otherwise, it would throw a runtime error, saying object is not initialized
Good Luck
Kumar

Kumar Reddi
0
kumar
11/13/2004 3:01:26 PM
Thx for you fast reply...

I' am sorry for asking but can you pls give me an example how to manage this ?
0
Oss_Newbie
11/13/2004 3:11:33 PM
Maybe it talks better if i put some code:

my ascx file named header.ascx:

<script runat="server">
Public blVisible as Boolean '' boolean to control lblCustom.visible
Public strMessage as string '' string to control lblCustom.text
</script>

<asp:label id=lblCustom runat="server" ></asp:label>
etc etc etc

my aspx file:

<%@ import Namespace="System.Web.Security" %>
<%@ Page Language="vb" debug="true" %>
<%@ import Namespace="System.Data.OleDB"%>
<%@ import Namespace="System.Data"%>
<%@ import Namespace="Control.ControlUsers"%>
<%@register TagPrefix="test" TagName="Header" src="Header.ascx" %>
<%@register TagPrefix="test" TagName="Menu" src="Menu.ascx" %>
<HTML>
<HEAD>
<title>Inloggen</title>
<script runat="server">

Sub Login(Byval obj As Object,Byval e As EventArgs)
dim objUser As new Control.User
dim objSB As new Control.Products
dim intID As integer

intID = objUser.Login(tbUsername.text,tbPassword.Text)
if intID <> 0 then
Session("UserID") = intID
'Here i have to code something so i can control lblCustom in my headerfile
'check if user has a cart
if not objSB.CartExists(intID) then
objSB.AddCart(intID)
end if

FormsAuthentication.RedirectFromLoginPage(intID,false)
else
lblMessage.text = "<font color=red> Geen geldig login of wachtwoord</font>"
end if
end sub
</script>
</HEAD>
<body bgColor="lightskyblue">
<table height="100%" cellSpacing="0" cellPadding="0" width="100%">
<test:HEADER id="Header1" runat="server"></test:HEADER>
<tr>
<test:MENU id="Menu1" runat="server"></test:MENU>
''etc ...etc...

So pls can you help me ?
0
Oss_Newbie
11/13/2004 4:11:10 PM
In your Page_Load declare a reference for HEADER

protected HEADER Header1;

Now in the place where you have to modify the text of the label
Header1.lblCustom.Text = "whatever You want"
Thats all you have to do
Kumar
Kumar Reddi
0
kumar
11/13/2004 4:36:34 PM
Hi Kumar,

Thanks for your help.
I understand what you mean but somehow i can't get it to work.
I receice the error:
BC30205: End of statement expected.
in my Page_load
Protected HEADER Header1;
This thing really drives me crazy, must be something small but can't figure it out..
Any idea's ??
0
Oss_Newbie
11/14/2004 12:45:18 PM
Oops. My bad. First of all I thought its C#, then I told you do declare it in Page_Load. I wasnt thinking when I said that.

You should put it outside the Page_Load, where you actually declare the class level variables.
Protected Header1 as HEADER
Sorry for the confusion
Good Luck
Kumar Reddi
0
kumar
11/14/2004 3:36:05 PM
Thx for your help !!

Any idea's for the email issue ?
0
Oss_Newbie
11/15/2004 8:55:01 PM
Reply:

Similar Artilces:

How to get user control id of ASPX page from ascx page..
Hi I have 1 user control which i m using in my aspx page 3 times..... my problem is that i want to get all these thee id of user control (which is in aspx page) from ascx page...whenever any button is clicked within user control....lets have a sample...<uc:RTB ID="RTBText" runat="server" RichTextBoxHeight="130"/><uc:RTB ID="RTBSummary" runat="server" RichTextBoxHeight="130"/><uc:RTB ID="RTBAffilation" runat="server" RichTextBoxHeight="130"/> here 3 user control i have de...

issue:not able to get ID of Control in aspx page on .ascx page
hai there, im trying to get the ID of the control  which im using  .ASPX page  into  the  .ASCX page Is that possible?assume that having  a grid in aspx page and an usercontrol in .ascx page(one textbox and a submit button) here i want to update  the DB and reflect in the grid  once i click the submit button,since its is a user control click event i have writen  submit_click event in  .ASCX, here i was not able to get the grid id to bind the data to it   is that possible,prakash      One sim...

How to pass textbox control value from UserControl page(ascx) to Page Control(aspx).
I have 2 files(aspx and ascx). the aspx page  has a Web user control(ascx) in it.Once the button control click(in aspx) I want to get the value from the textbox(ascx) controland pass it to label control in aspx page.Can somebody help with this and please use VB.Thanks A simple search would have turn up many different solutions.  The easiest is to just expose the textbox value as a property in your control.  Then you can retrieve that value on the aspx page. Add this to your control: Public Property TextBoxValue() As String   Get   &...

Control Menu in ascx page from aspx page
Hi all, Hope you can help. I have a menu in an ascx page that I want to change the visible status on based on whether a user is authenticated or not. If on the aspx page I try to change the state of the menu, I get the error that the menu is protected. I have very limited programming experience and can't find any info on this All help is welcome   Argy     In the Page_Load() Event, do this: If Page.User.Identity.IsAuthenticated = True Then Menu1.Visible = False Else Menu1.Visible = True End If  Specializing in...

Getting .ascx control value from aspx page
I have a three controls within a aspx page. I'm trying to access there values(textboxes, radiobuttonlists etc) from the aspx page. For example, a submit button on the aspx page, I want to get the values from control1,control2 control 1 = PricingInformation.ascx control 2 = BillingInformation.ascx ASPX page = EcommerceInformation.aspx --EcommerceInformation.aspx Protected PricingControl As PricingInformation Protected BillingControl As BillingInformation Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click ...

Paging Paging Paging
I am trying to do paging with my search results and it isnt working very well. Here is what I've tried and I feel I've tried everything, lol, please help me out. Sub DataGrid1_SortCommand(Sender as object, e as DataGridSortCOmmandEventArgs) DataGrid1.DataBind() End Sub Sub Datagrid1_PageIndexChanged(Sender as object, e as DataGridPageChangedEventArgs) Dim ds as dataSet DataGrid1.CurrentPageIndex = e.NewPageIndex if Session("Search") is nothing then 'Session probably has expired, get the datasource from database Datagrid1.DataSource = ...

How to get a variable from a web page (.aspx) in a user control (.ascx)
I have a web page with a dropdownlist and a usercontrol.  I would like the usercontrol to be able to read what the selected value is in the dropdownlist.   Any ideas on how this can/should be done are greatly appreciated. I'd suggest that you expose a public property on the Control and have the Page set this when the page does it's postback, for the control to consume. I have a page where I need to get the values from a DropDown prior to postback so I've got a public String and I set the variable whenever ddlYear_SelectedIndexChanged is called.  I also set i...

how to pass ddl1.selectedvalue from a content page to a User Control page ( ascx page)
 Hi All,I have a DropDownList in a content page. i would like to access its selectedvalue my user control page. the below is DDL<asp:dropdownlist id="ddl1" runat="server" autopostback="true">            <asp:listitem value="6" >6</asp:listitem>            <asp:listitem value="12" >12</asp:listitem>            <asp:listitem value="24"...

Control of the page and the controls on a page
I am building a web app that has some pages that are public and some that are only available based on subscription. Could someone explain the best way (infrastructure wise) how to control whether a server control is visible or enabledand how to control whether a page is viewable or not based on the user and whether or not the user is logged in (or not). If a user is not logged in I would like some controls to be visible but disabled. I also have to control the URL's in case a person learnsthe URL and tries to type it in. My question is more towards how to do this database wise. I am u...

Getting things back in Start Page and things out of Start Page
I know I posted over a year ago about this same question, I can not find my original post though. I know I posted it and I did find the solution and posted the sollution but I can not find it anywhere here again. They really need a better search engine on these forums. Is there any tools out there to help manage the start page? For example. I have projects that are on a web server I access them on the remote server. Well the start page never ever shows any updates for it the date posted as last access is the day I created it, However this is one of my more used projects. This one is so b...

from aspx page to aspx page
Hi,Apology if this was explained in another post but I need to understand:  Here is my issue: I have an input form that sends user input to a web service....and I would like the returned results on another page.Now the problem I have is  I would like to carry the content of textboxes on my form to the next page which displays the results. And be able to reference it there: i.einp.crrequest.applicant(1).address(1).postcode = (form)Me.txtPostcode.Text  regards Critical      Check out this link on various options to pass data across forms...

i have 3 pages student information , i filled two pages ,then go to 3rd page . First Two pages iam having 100 controls.how to store that controls and how to send these controls into 3rd page in ?
i have 3 pages student information , i filled two pages ,then go to 3rd page . First Two pages iam having 100 controls.how to store that controls and how to send these controls into 3rd page in ?  There are a number of ways storing values. Check out: http://msdn2.microsoft.com/en-us/library/75x4ha6s.aspxhttp://www.csharphelp.com/archives/archive207.html Thanks,Karan~ Remember To Mark The Post(s) That Helped You As The ANSWER ~ Hi, Welcome to asp.net forums. Now as far as your requirements goes, the first thing that strikes me is that 100 controls are way too many to kee...

accessing a dynamically loaded child's page user controls(ascx) from a parent page(aspx)
hi all,i've search the forums and i still can't get it to work.ok here goes...i've created a dropdownlist in the parent(aspx) page, this dropdown will post-back on and load a different child(ascx) page onto a Placeholder each time the user chooses a different selection in the dropdownlist.in the child(ascx) page, say i have a textbox. in the parent(aspx) page, i have a submit button.the placeholder loads accordingly to the dropdownlist's selection, so that is ok.so now the problem is, how do i capture the text in the textbox inside the child(ascx) page from the parent(aspx) p...

Getting "The page cannot be displayed" on aspx page that contains ajax toolkit controls
Hi, I am working on a .net project that uses the ajax control tool kit on a few aspx pages. When ever i try to access an aspx page that has toolkit controls (modalpopup, popupcontrolextender etc), i get the annoying error message  "page cannot be displayed". This happens only when i access the website after publishing it (from the published folder). However it works fine when i run the project from VS2005 IDE  I am using forms based authentication and have the following directory structure. C:\inetpub\wwwroot\TestWebsite -- contains login page and other static data pag...

Web resources about - Controlling ascx page in aspx page - asp.net.getting-started

Talk:Controlling for a variable - Wikipedia, the free encyclopedia
This article is within the scope of the WikiProject Statistics , a collaborative effort to improve the coverage of statistics on Wikipedia. If ...

Controlling What You Share on Timeline - Facebook
Facebook and Privacy hat eine Notiz mit dem Titel Controlling What You Share on Timeline geschrieben. Du kannst den vollständigen Text hier lesen. ...

VidReverse-Reverse Video by controlling video speed and by adding your own music to video easily on the ...
Get VidReverse-Reverse Video by controlling video speed and by adding your own music to video easily on the App Store. See screenshots and ratings, ...

Controlling a Computer with Eyes - Flickr - Photo Sharing!
Some folks know I work with assistive technology, and this shot is one from many I took in the last few days at a conference in Phoenix. This ...

4 year old little girl feeding and controlling 6 pitbulls - YouTube
As you see this video check out this other video of 2 kids playing with 3 huge pitbulls they just met in a pet store : https://www.youtube.c ...

Controlling the minds of cockroaches using Microsoft's Xbox Kinect
Late last year, you were introduced to real, live, remote-controlled cockroaches. Well, the insect hackers at the North Carolina State University ...

CONTROLLING CHAOS: Twitter's Wild Ride From Doodle To IPO
CONTROLLING CHAOS: Twitter's Wild Ride From Doodle To IPO Business Insider Australia “We apologise if the following profile lacks our usual ...

View from the Street: Power to the people controlling the power!
Your news of the day, reduced to a snarky rant.

Dying to be clean: The new technique for controlling feral cats
Cleanliness may be next to godliness unless you're a feral cat, in which case, cleanliness may get you a place next to god. In kitty heaven, ...

Man accused of 'controlling', beating wife faces ACT court
A man who allegedly controlled his wife’s life by beating her, taking her wages, checking her phone, stopping her from driving and indecently ...

Resources last updated: 12/13/2015 1:31:00 PM