473,387 Members | 1,530 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Tricky page structure

Hello everyone. I'm having a problem with accessing components. I've looked
for a solution in other forums but until now no one have given me any tiny
clue about how could I solve it. I know there is a solution to it, but, I
couldn't find one. I have a webpage in a website with the the following
structure:

Main MasterPage

LoginView

ContentPlaceHolder

Child MasterPage

Table with 2 columns
ContentPlaceHolder1 (in column 1)
ContentPlaceHolder2 (in column 2)
Than I set a regular content page based on the child MasterPage. In the
content for the ContentPlaceHolder1, I put a RadioButtonList or a button. It
shoul trigger an UpdatePanel I put in the content for the ContentPlaceHolder2.

First of all, at runtime, the RadioButtonList couldn't be found by it's
ID. So, I did some research and a lot of peopel, with a more simple structure
seemed to solve their problem with dynamic registering the RadioButtonList as
a trigger. Aparently, the trick was using the RadioButtonList UniqueID as the
ControlID for the trigger. And to put al the code in the Page_Init() method.

My very problem is that I simply can't write a working code to find the
UniqueID. Currently, the (not working) code that I have (in the Iis:

protected void Page_Init()
{
if (IsPostBack)
{
LoginView lv = (LoginView)Master.Master.FindControl("LoginView1")
; //hardcoded in the main Masterpage
ContentPlaceHolder cph_dados = (ContentPlaceHolder)lv.FindControl
("ph_conteudo_principal").FindControl("ph_dados "); //hardcoded in the child
masterpage
ContentPlaceHolder cph_tabela = (ContentPlaceHolder)lv.
FindControl("ph_conteudo_principal").FindControl(" ph_tabela"); //hardcoded
int the child masterpage

AsyncPostBackTrigger trg_cmd_calcula = new AsyncPostBackTrigger()
;
trg_cmd_calcula.ControlID = ((Button)cph_dados.FindControl
("cmd_calcula")).UniqueID.ToString(); // this example is with a button in the
content page, in cph_dados
((UpdatePanel)cph_tabela.FindControl("udp_gridview ")).Triggers.
Add(trg_cmd_calcula);
}
}
Thanks in advance for any help.

Juliano

Jun 27 '08 #1
2 1305
one of the problems of using control ids instead of the actual control is the
limitations of control search. for the control to found by id, the control
seaching (AsyncPostBackTrigger in your case), and the control its looking for
must have the same naming container. the find will search one naming
container deep.

in your case the naming container for the update panel is
ContentPlaceHolder2, this means the trigger control must be a child of this
container.

to do what you want you will need to create a dummy trigger in
ContentPlaceHolder2, then in client code, have the actual trigger in
ContentPlaceHolder1 fire the click event of the dummy trigger. the client
code will need the ClientID of the dummy trigger.

-- bruce (sqlwork.com)
"jpavel" wrote:
Hello everyone. I'm having a problem with accessing components. I've looked
for a solution in other forums but until now no one have given me any tiny
clue about how could I solve it. I know there is a solution to it, but, I
couldn't find one. I have a webpage in a website with the the following
structure:

Main MasterPage

LoginView

ContentPlaceHolder

Child MasterPage

Table with 2 columns
ContentPlaceHolder1 (in column 1)
ContentPlaceHolder2 (in column 2)
Than I set a regular content page based on the child MasterPage. In the
content for the ContentPlaceHolder1, I put a RadioButtonList or a button. It
shoul trigger an UpdatePanel I put in the content for the ContentPlaceHolder2.

First of all, at runtime, the RadioButtonList couldn't be found by it's
ID. So, I did some research and a lot of peopel, with a more simple structure
seemed to solve their problem with dynamic registering the RadioButtonList as
a trigger. Aparently, the trick was using the RadioButtonList UniqueID as the
ControlID for the trigger. And to put al the code in the Page_Init() method.

My very problem is that I simply can't write a working code to find the
UniqueID. Currently, the (not working) code that I have (in the Iis:

protected void Page_Init()
{
if (IsPostBack)
{
LoginView lv = (LoginView)Master.Master.FindControl("LoginView1")
; //hardcoded in the main Masterpage
ContentPlaceHolder cph_dados = (ContentPlaceHolder)lv.FindControl
("ph_conteudo_principal").FindControl("ph_dados "); //hardcoded in the child
masterpage
ContentPlaceHolder cph_tabela = (ContentPlaceHolder)lv.
FindControl("ph_conteudo_principal").FindControl(" ph_tabela"); //hardcoded
int the child masterpage

AsyncPostBackTrigger trg_cmd_calcula = new AsyncPostBackTrigger()
;
trg_cmd_calcula.ControlID = ((Button)cph_dados.FindControl
("cmd_calcula")).UniqueID.ToString(); // this example is with a button in the
content page, in cph_dados
((UpdatePanel)cph_tabela.FindControl("udp_gridview ")).Triggers.
Add(trg_cmd_calcula);
}
}
Thanks in advance for any help.

Juliano

Jun 27 '08 #2
Hi, Bruce. Well, I thought I could register any control in the page as a
trigger (at least is what says Mathew MacDonald in his Asp.net book). Well,
let's suppose he's wrong and try to use a dummy trigger. When I click a
button to fire the dummy trigger, won't i postback the whole page, including
the updatePanel? In this case, I loose the Asynchronous feature of the Ajax.
Am I wrong? Sorry if this is a silly question.

Juliano

bruce barker wrote:
>one of the problems of using control ids instead of the actual control is the
limitations of control search. for the control to found by id, the control
seaching (AsyncPostBackTrigger in your case), and the control its looking for
must have the same naming container. the find will search one naming
container deep.

in your case the naming container for the update panel is
ContentPlaceHolder2, this means the trigger control must be a child of this
container.

to do what you want you will need to create a dummy trigger in
ContentPlaceHolder2, then in client code, have the actual trigger in
ContentPlaceHolder1 fire the click event of the dummy trigger. the client
code will need the ClientID of the dummy trigger.

-- bruce (sqlwork.com)
>Hello everyone. I'm having a problem with accessing components. I've looked
for a solution in other forums but until now no one have given me any tiny
[quoted text clipped - 59 lines]
>>
Juliano
--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/For...p-net/200804/1

Jun 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Jyrki Keisala | last post by:
I have an XML file: <document> <record> <element1>Text</element1> <element2>More text</element2> <element3>Even more text</element3> <element4>Some text <link><title>Google</title><url>...
2
by: M2 | last post by:
Hi All, I'm trying to move an application of mine into the 21st century and ditch the table intensive layout in favour of CSS. Where I am stumbling can be seen here: ...
1
by: Roger Withnell | last post by:
My website has a dynamic navigation bar which the administrators of the site can design. It's structure is held in an SQL database. It is displayed on every page of the website. For a browser,...
3
by: rittersporn | last post by:
I want to model relations between "Groups" and also annotate the relations! My solution so far: Group - GroupName : Text | PRIMARY_KEY - Titel : Text - Info : Memo
5
by: Hardy Wang | last post by:
Hi all: I developed a web site, it passed various testing internally. When I put this site in production, I receive some error reports from this site saying "the viewstate is invalid for this page...
4
by: VB Programmer | last post by:
I have a function that returns a datareader. The problem is that in the function's FINALLY I close the datareader and set it to nothing. But, BEFORE the Finally I "Return" the datareader (in the...
2
by: pruebauno | last post by:
I am currently working on a tricky problem at work. I googled around a bit, but "time intervals" did not come up with anything useful. Although I have some rough idea of how I could solve it, I...
14
by: felixnielsen | last post by:
Consider this 3d vector: const SIZE = 'some_size'; std::vector<std::vector<std::vector<char> > >GRID(SIZE, std::vector<std::vector<char> >(SIZE, std::vector<char>(SIZE))); It can be viewed...
3
by: jl | last post by:
Hi everybody! I have an interesting problem - and so far, I haven't been able to solve it. Maybe somebody else has an idea... I have a source xml structure that comes from a legacy system. It...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
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...
0
Oralloy
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,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.