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
bruce barker - 30 Apr 2008 17:08 GMT
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
jpavel - 30 Apr 2008 20:23 GMT
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
>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
[quoted text clipped - 18 lines]
>>
>> Juliano