Showing posts with label view. Show all posts
Showing posts with label view. Show all posts

Monday, March 26, 2012

UpdatePanel & Form View in Web Site Project vs. Web Application Project

I am seeing two different behavour patters when using the UpdatePanel in a Web Application Project (File > Add New Project > ASP.NET AJAX-Enabled Web Application) vs a Web Site Project (File > New Website > ASP.NET AJAX-Enabled Web Site)

The exact same code will complie in one project type but not in another.

The code is:

<

asp:FormViewID="FormView1"runat="server"> <EditItemTemplate> <asp:UpdatePanelID="UpdatePanel1"runat="server"> <ContentTemplate> <asp:LabelID="Label1"runat="server"Text="Label"></asp:Label> </ContentTemplate> </asp:UpdatePanel> </EditItemTemplate> <InsertItemTemplate> <asp:UpdatePanelID="UpdatePanel1"runat="server"> <ContentTemplate> <asp:LabelID="Label1"runat="server"Text="Label"></asp:Label> </ContentTemplate> </asp:UpdatePanel> </InsertItemTemplate></asp:FormView>If you have this code in a single page Web Application Project it will complie and run just fine. However if you have this code in a Web Site Project it will not complete. It complains that you have already declared Label1 in this class. SInce Label1 is inside two different FormView templates this should complie.

Does anyone know a resolution for this other than converting to using Web Application Projects instead of Web Site Projects?

Thanks In Advance
Martin

p.s. Using most recient System.Web.Extensions downalod (1.0.61025.0)

Nevermind. The Web Application Project does not complete the aspx file so it does not fail until you try to run the code.

I guess its another issue as to why the UpdatePanel forces you to rename your controls differently within each template of the formview control.

Martin

Saturday, March 24, 2012

UpdatePanel and custom Extender: two components with the same id cant be added to the appl

I am experiencing some strange behavior in my UpdatePanel which contains a ListView with a DataPager control. The items in the list view each have a custom ModalPopupExtender that is dynamically generated as well as a custom extender control that does some manipulation on an image.

The first page of results loads correctly, and I can move to the next page fine as well. However, when I move back to the first page, Firebug shows me the 'two components with the same id can't be added to the application' exception thrown on each of the items on the first page of the list, on the behavior associated with my custom extender. This to me seems that the partial update does not destroy or dispose the extender's behaviors when I move to the next page, so when I try to render the first page again, those extenders are still sitting in memory.

Now the kicker is, if I go to the next page and back to the first page a second time, my behaviors load correctly. Repeat and they don't show up and new errors are fired. I know this has to do with the lifecycle but I can't seem to pin it down.

Now my custom extender is fairly straightforward and only calls the base dispose() method for its own dispose() function. What am I missing?


I have narrowed down the issue to the fact that the Extender control uses a callback to attach an event to an image that has loaded dynamically from a web service call:

_onMethodComplete : function(result, userContext, methodName)
{
// Wire up image effect
var i = this.get_element();
i.onload = function(i)
{
asyncEffect(i); // This function lives in an external effects.js file
}

// Do after onload event to pick up change
this._setImage(result);
}

Doing this prevents the extender from disposing, possibly because it's still got a handle to an external JS file. I blanked out the image's onload event after the effect completes and the extender works for images that weren't previously on the page, but is still not disposing the extender correctly. Commenting out the wire up code above corrects the issue (obviously without the effects the JS file would bring).

How can I cleanly dispose an extender that references an external JS script?

Wednesday, March 21, 2012

UpdatePanel and MultiView

Fellows, I don't know if this is a bug or just a mistake, but when I place a UpdatePanel inside a view, of a multiview, that isn't the activeview, I've got an JS error... the problem is at the follow sentence:

<script type="text/javascript">
Web.WebForms.PageRequestManager._setupAsyncPostBacks(document.getElementById('aspnetForm'), 'ctl00$ScriptManager1', ['ctl00_ContentPlaceHolder1_UpdatePanel1', 'ctl00_ContentPlaceHolder1_UpdatePanel2'], []);
</script>

it tries to access 'ctl00_ContentPlaceHolder1_UpdatePanel2' but this updatepanel is inside another view and cannot be rendered...

Well, if it was my fault or if someone have a work around, please answer me... if it is a bug, there is my feedback... :-)

Thanks a lot...

Wender

Try including the entire MultiView within the UpdatePanel instead. I tried this and it works beautifully.

Hello jcasp, thanks for your reply.

I also tried this but didn't work. I really need two updatepanels... one for each view...

But, I added 2 lines at Atlas.js just to check if some updatepanel is null and now it's working. I think that at some version in the future it will works...

Thanks again...

Wender


What lines did you change?
Hi,

this may be related to a known bug about the UpdatePanel's ID. An error is raised when the UpdatePanel's ID contains an underscore '_' character.

updatepanel and pagesource in browser

I have an updatepanel with a gridview
The paging works perfect.

When I view the pagesource when Im on page 1 in the gridview I can see the values that are displayed to the end-user (for example username, age and some user comment)
When I go to the second page, the end-user can see the values in the gridview as intended, but when I view the page source I cant find the displayed values.

So where does this text actually reside? Im used to that in the pagesource I can always view what is displayed to the end-user.


Hello,

most browsers will show you the page source as it was the first time you loaded the page. With Ajax you are changing parts of the page after it has loaded. If you want to get real insight into the changes try theFirebugadd-on for Firefox. It will show you the page source in a nice collapsible treeas it is, live. Also, you can use it to check out the communication to and from the server during an Ajax call and much much more.

Good luck!