469,898 Members | 1,581 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,898 developers. It's quick & easy.

dynamic controls + ajax

Gui
Hi, I'm working in C# .net 2005 with Ajax.

I have a page that loads dynamic user controls depending on the
scenario. In those user controls, I create dynamic linkbuttons. The user
controls are loaded on the .aspx PageLoad and the linkbuttons are
created on the .ascx PageLoad. The problem I have is that those
linkbuttons don't work on the first click. I have to make 2 clicks to
have their event fired. What can I do for that ?

Thanks.
Jun 13 '07 #1
5 1719
Hi

Do you remove any dynamically created controls from the page or ASCX in response
to any server event?
Do you assign IDs to the dynamically created link buttons?

It is possible that IDs of dynamically created controls change and server
even is not fired in response to click if you re-create link buttons with
different ID. It is possible if you change structure of the page.

-yuriy
Hi, I'm working in C# .net 2005 with Ajax.

I have a page that loads dynamic user controls depending on the
scenario. In those user controls, I create dynamic linkbuttons. The
user controls are loaded on the .aspx PageLoad and the linkbuttons are
created on the .ascx PageLoad. The problem I have is that those
linkbuttons don't work on the first click. I have to make 2 clicks to
have their event fired. What can I do for that ?

Thanks.

Jun 13 '07 #2
Gui

Well, I my buttons have an ID, but I've just found that their ID change
after the first click. When they load the first time, I have something
like id="ctl05_btnGroup1", "ctl05_btnGroup2", etc. After the first
click, they change to id="ctl04_btnGroup1", "ctl04_btnGroup2", etc.

I've compared the complete source code between "Before" and "After"
first click and there are some differences in the ViewState and
everywhere I have ctl05 in the first source, it became ctl04 in the
second. Do you have any idea why it changes like that ?

Right now, I don't think I remove dynamically created controls. I'll
look again.

thanks
Hi

Do you remove any dynamically created controls from the page or ASCX in
response to any server event? Do you assign IDs to the dynamically
created link buttons?
It is possible that IDs of dynamically created controls change and
server even is not fired in response to click if you re-create link
buttons with different ID. It is possible if you change structure of
the page.
-yuriy
>Hi, I'm working in C# .net 2005 with Ajax.

I have a page that loads dynamic user controls depending on the
scenario. In those user controls, I create dynamic linkbuttons. The
user controls are loaded on the .aspx PageLoad and the linkbuttons are
created on the .ascx PageLoad. The problem I have is that those
linkbuttons don't work on the first click. I have to make 2 clicks to
have their event fired. What can I do for that ?

Thanks.

Jun 14 '07 #3
Gui

How can I make sure that the ID's will not change since the "ctl05" part
is generated by aspnet ? I tried creating them on Page_Init instead of
Page_Load but no success... I have like 5 placeholder that load user
controls dynamically, but I never have 2 user controls loaded at the
same time... I don't understand why the IDs are changing by themselves...
If you can assign the same ID to your controls you will solve your
problem. events are not fired due to changes in IDs.
>Well, I my buttons have an ID, but I've just found that their ID
change after the first click. When they load the first time, I have
something like id="ctl05_btnGroup1", "ctl05_btnGroup2", etc. After the
first click, they change to id="ctl04_btnGroup1", "ctl04_btnGroup2",
etc.

I've compared the complete source code between "Before" and "After"
first click and there are some differences in the ViewState and
everywhere I have ctl05 in the first source, it became ctl04 in the
second. Do you have any idea why it changes like that ?

Right now, I don't think I remove dynamically created controls. I'll
look again.

thanks
>>Hi

Do you remove any dynamically created controls from the page or ASCX
in
response to any server event? Do you assign IDs to the dynamically
created link buttons?
It is possible that IDs of dynamically created controls change and
server even is not fired in response to click if you re-create link
buttons with different ID. It is possible if you change structure of
the page.
-yuriy
Hi, I'm working in C# .net 2005 with Ajax.

I have a page that loads dynamic user controls depending on the
scenario. In those user controls, I create dynamic linkbuttons. The
user controls are loaded on the .aspx PageLoad and the linkbuttons
are created on the .ascx PageLoad. The problem I have is that those
linkbuttons don't work on the first click. I have to make 2 clicks
to have their event fired. What can I do for that ?

Thanks.

Jun 14 '07 #4
What control do 'ctl04' and 'ctl05' prefixes come from? Is it a repeater
or something else?
It looks like before the first click you page contained some other control
before. After the first click this control was not longer created. I beleive
that this is due to change in your scenario. If you can assign unique IDs
to these controls (Naming containers for your buttons) it should solve your
problem.

-yuriy
How can I make sure that the ID's will not change since the "ctl05"
part is generated by aspnet ? I tried creating them on Page_Init
instead of Page_Load but no success... I have like 5 placeholder that
load user controls dynamically, but I never have 2 user controls
loaded at the same time... I don't understand why the IDs are changing
by themselves...
>If you can assign the same ID to your controls you will solve your
problem. events are not fired due to changes in IDs.
>>Well, I my buttons have an ID, but I've just found that their ID
change after the first click. When they load the first time, I have
something like id="ctl05_btnGroup1", "ctl05_btnGroup2", etc. After
the first click, they change to id="ctl04_btnGroup1",
"ctl04_btnGroup2", etc.

I've compared the complete source code between "Before" and "After"
first click and there are some differences in the ViewState and
everywhere I have ctl05 in the first source, it became ctl04 in the
second. Do you have any idea why it changes like that ?

Right now, I don't think I remove dynamically created controls. I'll
look again.

thanks

Hi

Do you remove any dynamically created controls from the page or
ASCX
in
response to any server event? Do you assign IDs to the dynamically
created link buttons?
It is possible that IDs of dynamically created controls change and
server even is not fired in response to click if you re-create link
buttons with different ID. It is possible if you change structure
of
the page.
-yuriy
Hi, I'm working in C# .net 2005 with Ajax.
>
I have a page that loads dynamic user controls depending on the
scenario. In those user controls, I create dynamic linkbuttons.
The user controls are loaded on the .aspx PageLoad and the
linkbuttons are created on the .ascx PageLoad. The problem I have
is that those linkbuttons don't work on the first click. I have to
make 2 clicks to have their event fired. What can I do for that ?
>
Thanks.
>

Jun 14 '07 #5
Gui
Ok, I think I've found out the problem. Those "ctl05" came from the
PlaceHolder. The problem I got was because I was loading the user
control two times in a row the first time I loaded it. So after the
first "two loading", when I clicked on a link button, it loaded the page
only once and after that it was working. I found out a way to prevent
this and it seems to work correctly now !

Thanks a lot.
What control do 'ctl04' and 'ctl05' prefixes come from? Is it a
repeater or something else? It looks like before the first click you
page contained some other control before. After the first click this
control was not longer created. I beleive that this is due to change in
your scenario. If you can assign unique IDs to these controls (Naming
containers for your buttons) it should solve your problem.
-yuriy
>How can I make sure that the ID's will not change since the "ctl05"
part is generated by aspnet ? I tried creating them on Page_Init
instead of Page_Load but no success... I have like 5 placeholder that
load user controls dynamically, but I never have 2 user controls
loaded at the same time... I don't understand why the IDs are changing
by themselves...
>>If you can assign the same ID to your controls you will solve your
problem. events are not fired due to changes in IDs.

Well, I my buttons have an ID, but I've just found that their ID
change after the first click. When they load the first time, I have
something like id="ctl05_btnGroup1", "ctl05_btnGroup2", etc. After
the first click, they change to id="ctl04_btnGroup1",
"ctl04_btnGroup2", etc.

I've compared the complete source code between "Before" and "After"
first click and there are some differences in the ViewState and
everywhere I have ctl05 in the first source, it became ctl04 in the
second. Do you have any idea why it changes like that ?

Right now, I don't think I remove dynamically created controls. I'll
look again.

thanks

Hi
>
Do you remove any dynamically created controls from the page or
ASCX
in
response to any server event? Do you assign IDs to the dynamically
created link buttons?
It is possible that IDs of dynamically created controls change and
server even is not fired in response to click if you re-create link
buttons with different ID. It is possible if you change structure
of
the page.
-yuriy
>Hi, I'm working in C# .net 2005 with Ajax.
>>
>I have a page that loads dynamic user controls depending on the
>scenario. In those user controls, I create dynamic linkbuttons.
>The user controls are loaded on the .aspx PageLoad and the
>linkbuttons are created on the .ascx PageLoad. The problem I have
>is that those linkbuttons don't work on the first click. I have to
>make 2 clicks to have their event fired. What can I do for that ?
>>
>Thanks.
>>

Jun 14 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Lloyd Sheen | last post: by
reply views Thread by Gui | last post: by
9 posts views Thread by pbd22 | last post: by
2 posts views Thread by oaksong | last post: by
1 post views Thread by David | last post: by
1 post views Thread by John Straumann | last post: by
5 posts views Thread by Hans Kesting | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.