PC Review


Reply
Thread Tools Rate Thread

Controls traversing

 
 
abcd
Guest
Posts: n/a
 
      2nd Dec 2009
Let me know if you know this.

I have Aspx page with below control structure.

AjaxTabContainer
- ReceiptPanel
? Literal
? ReportViewer

- EmailPanel
o UserControl
? TextBox1
? TextBox1
? Button

I want to access the ReportViewer control from Button action.

I tried

var rptVw = (ReportViewer)
Parent.Parent.Parent.Controls[0].Controls[1].Controls[1];

This works but looks ugly. Also I dont want to search the control by its ID.
[I dont want hardcoding so that it can be used multiple places]

I am blind at this moment. Do you see efficient way to reach to
ReportViewer, from the button action.

 
Reply With Quote
 
 
 
 
Gregory A. Beamer
Guest
Posts: n/a
 
      2nd Dec 2009
"abcd" <(E-Mail Removed)> wrote in
news:B060C593-4764-4B2C-B8CB-(E-Mail Removed):

> var rptVw = (ReportViewer)
> Parent.Parent.Parent.Controls[0].Controls[1].Controls[1];
>
> This works but looks ugly. Also I dont want to search the control by
> its ID. [I dont want hardcoding so that it can be used multiple
> places]
>
> I am blind at this moment. Do you see efficient way to reach to
> ReportViewer, from the button action.


You can make this a bit prettier by "asking" the control for its id and
emitting the JavaScript that "finds" it. It is a more maintainable solution
than Parent.Parent.Parent.Controls[0].Controls[1].Controls[1], as altering
the page may end up with the ReportViewer with a different ordinal value.

Other than that, I am not coming up with any brilliant ideas at the moment.

Peace and Grace,

--
Gregory A. Beamer (MVP)

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

*******************************************
| Think outside the box! |
*******************************************
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Traversing children controls of user control get extra controls df Microsoft ASP .NET 0 17th May 2006 10:55 PM
Traversing Controls elziko Microsoft VB .NET 2 12th Nov 2004 02:28 PM
traversing across columns in VBA Peter Bailey Microsoft Excel Programming 4 19th Oct 2004 06:59 AM
XML - traversing in VB Asad Microsoft ASP .NET 1 16th Apr 2004 03:20 AM
Traversing VBA.Collection Josh Microsoft C# .NET 1 31st Dec 2003 06:02 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:08 AM.