CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums




Can Reply:  No Members Can Edit: No Online: Yes
Zone: > NEWSGROUP > Asp.Net Forum > windows_hosting.hosting_open_forum Tags:
Item Type: NewsGroup Date Entered: 1/25/2004 11:15:06 AM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
NR
XPoints: N/A Replies: 5 Views: 401 Favorited: 0 Favorite
6 Items, 1 Pages 1 |< << Go >> >|
Haim_w
Asp.Net User
how to access parent container page HtmlGenericControl1/25/2004 11:15:06 AM

0

Is it possible to gain access within Server control to one of the parent container page HtmlGenericControl?
I?m looking for something equivalent to this.Parent.FindControl(?BodyTag?).Attributes.Add("bgcolor","black");
So I can set the Body.bgcolor attribute of my container page.
tinghaoy
Asp.Net User
Re: how to access parent container page HtmlGenericControl1/26/2004 6:27:04 PM

0

If your Html elements are indeed server side controls (with runat=server), you can always walk up the control hierarchy to find them.

For example:

<body runat=server id="BodyTag">
<form ruant=server>
....
</form>
</body>

void Page_Load() {
BodyTag.Attributes.Add("bgcolor", "black");
}



HTH,
Ting-hao


This posting is provided "AS IS" with no warranties, and confers no rights.
Haim_w
Asp.Net User
Re: how to access parent container page HtmlGenericControl1/27/2004 1:58:46 PM

0

I will try to sharp my question,
I developed a web control and I want to set the color of my container page, depending on one of the web control properties. I guess there are 2 options:

1. The easy and ugly way writing JavaScript Block from the server side :
<script language=?javaScript? For=?window? Event=?onload?>
document.bgColor = ?black?;
</script>

2. the nice way is to set the container page Body tag to runat=server and to set the BodyTag.Attributes.Add("bgcolor","black");
as you suggested.

My question refer to option number 2. will trying to access the BodyTag from the PreRender function in my control I?m having difficulties to find it in the Page hierarchy

My Code:


System.Web.UI.HtmlControls.HtmlGenericControl BodyTag = this.Parent.FindControl(?BodyTag?)


the problem ,as you can see FindControl return System.Web.Ui.Control
but I need System.Web.UI.HtmlControl to be return.
BSC_ZaP!
Asp.Net User
Re: how to access parent container page HtmlGenericControl1/27/2004 4:47:35 PM

0

FindControl() works by beginning at the control it was called upon and searching down. You would have to walk up the control tree: (C#)

Control c = this.Parent;
while(c.ID != "BodyTag") {
c = c.Parent;
}
HtmlGenericControl body = (HtmlGenericControl)c;

BSC

tinghaoy
Asp.Net User
Re: how to access parent container page HtmlGenericControl1/27/2004 6:21:55 PM

0

Yes, you will have to cast your return type.


System.Web.UI.HtmlControls.HtmlGenericControl BodyTag = (System.Web.UI.HtmlControls.HtmlGenericControl)Page.FindControl(?BodyTag?);


HTH,
Ting-hao
This posting is provided "AS IS" with no warranties, and confers no rights.
Haim_w
Asp.Net User
Re: how to access parent container page HtmlGenericControl1/28/2004 7:25:47 AM

0

Thanks for the help,
BSC example really worked
6 Items, 1 Pages 1 |< << Go >> >|


Free Download:


Web:
how to access parent container page HtmlGenericControl - ASP.NET ... how to access parent container page HtmlGenericControl ... within Server control to one of the parent container page HtmlGenericControl? ...
how to access parent container page HtmlGenericControl - ng.asp ... how to access parent container page HtmlGenericControl, > ROOT > NEWSGROUP > Asp .Net Forum > windows_hosting.hosting_open_forum, Date: 1/25/2004 11:15:06 AM ...
HtmlGenericControl Members Searches the current naming container for the specified server control. ... NET page is requested. public event Init (inherited from Control) ... Assigns any sources of the event and its information to the control's parent. ...
HtmlGenericControl Methods (System.Web.UI.HtmlControls) Searches the current naming container for the specified server control. ... delegate to render the server control and its content into its parent control. ... NET page framework to notify server controls that use composition-based ...
Custom Header in GridView - Stack Overflow WriteBeginTag("tr"); for(int i = 0; i < container.Controls. ... parent) { // TODO: should add css classes HtmlGenericControl label = new ... since I am using a Master page for this and the ID should be something much longer. ... the LinkButton's never find an IContainer parent to rewrite their ID's. ...
15 Seconds : Developing ASP+ Pages Using JScript.NET So, ASP+ has a control named HtmlGenericControl that is the super ... The page is a container that has all these controls stored in a hierarchy. ... We need to decide the hierarchy and add the controls to the appropriate parent control. ... that's more robust than Access may find MySQL to be a pleasant alternative. ...
can't get Me.FindControl to work 2nd enable trace in the content page and observe all of the parent containers using the FindControl on each of them... Master.FindControl(". ...
output control to html with oninit events - ASP.NET Forums Add(container); HtmlGenericControl div = new HtmlGenericControl("div"); ... Parent.Parent.Parent.ClientID + "', false)"); ... other controls are not certain to be created or ready for access. ... Page 1 of 1 (2 items) ...
Re: can't get Me.FindControl to work Your control and its parent containers will be easier to read and access. ... 2nd enable trace in the content page and observe all of the parent containers ...
Bloggism.net - Thursday byte: ASP.NET Server Control, Part One NET will simply use the HtmlGenericControl class. ... Parent - Gets a reference to the control’s parent, which can be the page or another container control. ... The control must be a container tag to have child controls (such as a
tag) . ... You should not access another server control during this event, ...






visual basic 20005 - connect access database

copyiong back and forth from developer machine to web server

advice on project

noticed something odd

is there a way of enabling preventing immediate content expiration in cassini?

asp.net 2.0 issues

signature of the body and declaration in a method implementation do not match...

intellisence not working in new class only

.net 2.0 user profiles

customer root designers - anyone got them to work in 2005b2?

app_code folder

absolute paths in designer

&hc0000005& error in visual studio 2005 pro

"obj" folder in library projects

need help in configuring aps.net 2.0

debugging unmanaged native dll in asp.net

freetextbox

file name only on designer's open file tabs.

web deployment project - exactly what have i created?

gridview data formatting

visual studio crashes when i edit a stylesheet

how does classdesigner deal with composition & aggregation ?

precompiled web site with fixednames not so fixed?

asp.net page model with code behind and server side script different to version 1.1

where are the log files located if you run the asp.net 2,0 app using the built-in webserver of vs 2005?

how can visual studio's f5 provide msbuild's power?

where's this five minute portal application i read about :s

enableviewstate property on page?

webforms request: consistent color chooser intellisense

how to open a file(ppt/doc/pdf) in contentplaceholder1 of masterpage

   
  Privacy | Contact Us
All Times Are GMT