473,725 Members | 2,118 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

AJAX UpdatePanel dynamic controls and RegisterStartUp Script click twice

149 New Member
Hi,

I have read hundreds of post regarding this issue, but none have an answer for my situation. So hopefully somebody here can help!

I have a gridview in an updatepanel (AJAX control toolkit) and because paging/sorting aren't supported I've added my own custom paging. I have dynamically loaded LinkButtons in the updatepanel to change the page but they only fire on the second click. I have also attached javascript to the rows so that they can be selected when you click. Again only the second click works.

I have DataBind in the event handlers and I only DataBind the first time when the page is loaded. When I debug the click events only fire the second time??

Any ideas?

Thanks in advance
Oct 31 '07 #1
23 16204
Frinavale
9,735 Recognized Expert Moderator Expert
Hi,

I have read hundreds of post regarding this issue, but none have an answer for my situation. So hopefully somebody here can help!

I have a gridview in an updatepanel (AJAX control toolkit) and because paging/sorting aren't supported I've added my own custom paging. I have dynamically loaded LinkButtons in the updatepanel to change the page but they only fire on the second click. I have also attached javascript to the rows so that they can be selected when you click. Again only the second click works.

I have DataBind in the event handlers and I only DataBind the first time when the page is loaded. When I debug the click events only fire the second time??

Any ideas?

Thanks in advance
I'd suggest taking the GridView out of the UpdatePanel.
Is there any reason why it has to be there?


Have you attempted moving the paging LinkButtons outside of the GridView (place them above or below or something).
Oct 31 '07 #2
rsdev
149 New Member
Hi Frinavale,

Thanks for responding!

I want the gridview in the updatepanel to create a seemles WYSIWYG CMS.

Once I've finished the demo I plan to open source the project and invite other developers to help improve it like a updated AJAX WYSIWYG version of DOTNETNUKE.

Anyway, the LinkButtons are outside the gridview they are dynamically created in placeholder below the gridview. But the javascript is obviously attached to each row of the gridview. So it must be a simple error on my part because both of these don't re-act on the first click. The updatepanel is in conditional mode with ChildTriggers set to true. I've read that I should create dynamic triggers for each of the dynamic controls but that doesn't explain why the javascript rows aren't working either.

I'm really stumped on this one!
Oct 31 '07 #3
Frinavale
9,735 Recognized Expert Moderator Expert
Hi Frinavale,

Thanks for responding!

I want the gridview in the updatepanel to create a seemles WYSIWYG CMS.

Once I've finished the demo I plan to open source the project and invite other developers to help improve it like a updated AJAX WYSIWYG version of DOTNETNUKE.

Anyway, the LinkButtons are outside the gridview they are dynamically created in placeholder below the gridview. But the javascript is obviously attached to each row of the gridview. So it must be a simple error on my part because both of these don't re-act on the first click. The updatepanel is in conditional mode with ChildTriggers set to true. I've read that I should create dynamic triggers for each of the dynamic controls but that doesn't explain why the javascript rows aren't working either.

I'm really stumped on this one!
I remember a while ago having the same problem (having to click twice)...but I can't remember how I got around it.

Let me see if I can't help you find something online regarding the issue.

-Frinny
Oct 31 '07 #4
Frinavale
9,735 Recognized Expert Moderator Expert
Do me a favour and try to link buttons that are not dynamically generated for your paging....does that fix anything?

And can you post the JavaScript responsible for selecting so that I can make sure there's nothing wrong here?

Just double checking before I get into looking up the event firing stuffs.
Oct 31 '07 #5
rsdev
149 New Member
Hi Frinny,

Thanks for sticking with this!

I've just tried adding a LinkButton (great suggestion) and have the same problem, nothing (response.write ) on the first click. It's like the first click isn't getting through to the server... somehow!

Here's the serverside added javascript;

Expand|Select|Wrap|Line Numbers
  1. protected void linksView_RowDataBound(object sender, GridViewRowEventArgs e)
  2. {
  3.             if (e.Row.RowType == DataControlRowType.DataRow)
  4.             {
  5.                 e.Row.Attributes["onmouseover"] = "this.style.cursor='hand';this.style.textDecoration='underline';";
  6.                 e.Row.Attributes["onmouseout"] = "this.style.textDecoration='none';";
  7.                 e.Row.Attributes["onclick"] = Page.ClientScript.GetPostBackClientHyperlink(this.linksView, "Select$" + e.Row.RowIndex);
  8.             }
  9. }
Thanks again!
Nov 1 '07 #6
rsdev
149 New Member
So in order to trace what was happening to the clicks, I decided to get a hardcore debugger. The Web Development Helper is very cool!

Now when I load the gridview in the updatepanel I checked the pages DOM and get a table with ID ...CMSControl_1 _linksView. When I click the button first time around the ID changes to CMSControl_ct10 4_linksView, then it remains the same. This has got to be the issue!!
Nov 1 '07 #7
rsdev
149 New Member
In fact it gets worse because all the javascript: __doPostBack code has used '$' instead of '_' for the ID's.

So how do I stop the gridivew table from changing ID and how do change the '$' for '_'?
Nov 1 '07 #8
rsdev
149 New Member
Don't worry about the '$' versus '_'. I've found out that doesn't make a difference.

But I still have the problem where I create the LinkButtons in Page_Load in a placeholder then the placeholder changes id after the first click so the event is never found or fired.
Nov 1 '07 #9
rsdev
149 New Member
So now I'm stuck not knowing how to make the LinkButton __DoPostBack the correct id??

Would ParseControl work better?
Nov 1 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

2
2813
by: brett | last post by:
I have an AJAX updatepanel in an aspx page. Inside the updatepanel is a placeholder control, which loads various ascx files. This all works fine. One of the ascx files also has an updatepanel in it. In the updatepanel is an ASP.NET image button that does a postback. So, it looks like this: aspx.updatepanel.Add(LoadControl(ascx control)) --ascx.updatepanel --imagebutton
4
2543
by: Rob Meade | last post by:
Hi all, I played with my first bit of AJAX the other week and was pleasantly surprised that I achieved my goal..now I'd like to try something else.. Question... If I have an updatePanel, and lets say I have a button as a trigger which runs a function in my code behind to add a textbox to the updatePanel, when the form is submitted does this control actually "exist" as such on the
8
2582
by: =?Utf-8?B?SmFrb2IgTGl0aG5lcg==?= | last post by:
I am new to AJAX. I am applying AJAX to a current web solution to get the "instant behaviour". On my main page I have two sets of criteria: Specific and Wide. Each set is placed in a View container. I am not sure that I configured the Triggers correct, but the behaviour is OK. When I click the linkbuttons they switch between two sets of search controls. When I click the search buttons they reload the display panel. BUT .... if the...
2
2212
by: =?Utf-8?B?VG9u?= | last post by:
Hello, I want to understand teh benefits of ajax technology. Does anyone has a good website where AJAX EXTENSIONS is worked out so I really understand it. There a 2 main questions: 1) How about the form load event. Why should it fire when I put a button in a update panel? Is this necessary and is only the other controls related to the update panel send back? Or the whole page (If this is true I really do not get it). But please answer...
3
8207
by: JacekDr | last post by:
Hello, I've got the following problem: I want to add and remove dynamically controls to UpdatePanel. In my user control I have a button, but when I click it I get AsyncPostback and Event for ButtonClick in UserControl doesn't fire. <asp:ScriptManager ID="ScriptManager" EnableViewState="true" runat="server" EnablePageMethods="True" >
7
1729
by: MikeB | last post by:
Hello All, I am new to ajax and wanted to start by trying something simple. I have a web form with an updatepanel and then inside the update panel I have a listbox. Then outside of the updatepanel I have a button. In my buttons click event in the cs / code behind, I have a loop that just inserts items in the listbox. My question is, once I click the button and the loop begins, how do I get it to update the listbox? Does this make since?...
1
8201
by: abellix | last post by:
An updatepanel contains a datagrid, this datagrid has columns generated by code-behind: some columns should have async postback, others should have sync postback. Here a sample to reproduce the behaviour: it's a webform with some VB code-behind, you shoud create a new AJAX-enabled application and past the following code. (DEFAULT.ASPX) <%@ Page Language="VB" AutoEventWireup="true" CodeFile="Default.aspx.vb" Inherits="_Default" %> <html...
4
5358
by: Peter | last post by:
ASP.NET I have an application which use ASP.NET Autocomplete extender which works great. But I have a question how to update all the fields on the screen using Ajax. Users starts typing in a text field which causes the Autocomplete extender to display 10 like items, after the users selects an item (which is a key in the database) I want the application to go to the database retrieve a record and populate the fields.
1
2064
by: raam | last post by:
Hi, I have ajax tab container with 6 tabs in it. I need to validate each tab contents separately and the validtaion summary must be separate for each tab. i cannot do that only one summary is being accesed. i also tried with validationgroup. Finlly i want each tab content to be validated and the content should accept the inputs.If any errors the message must display in summary separately. Here are 2 of my tabs.Dont feel bore pls let me...
0
8752
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9401
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9257
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9113
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6011
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4519
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3221
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2635
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2157
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.