Showing posts with label partial. Show all posts
Showing posts with label partial. Show all posts

Monday, March 26, 2012

probably simple but i am new - Trying to do a partial render on a master page for my navi

I am trying to learn ajax and i got off to a fairly good start but i am stuck on this one and couldnt find any answers on the net.. i understand the use of a script manager and a updatepanel i got it to work on a page with a tree and when you select a item it loads a picture into a imgbox and it works great but here is my problem

I have a master page.. on the master page it contains my navi bar. each of the 4 buttons opens a new content page (*.aspx). I am trying to set it up so the Navi bar doesnt reload everytime i open another content page.. i want just the contentplace holder to refresh.. I have tried putting a updatepanel around my navi bar but it just doesnt seem to work.. i know this is probably really simple and i want to thank everyone in advance.

Thanks

-steve

I think you were on track when u put update panel over your menu. Just make sure that the update panel UpdateMode=Conditional

This way it will only cause postback when some trigger or other method will make it to cause postback.

Here are some good tutorial on UpdatePanel and update methods.

http://www.asp.net/learn/ajax-videos/video-177.aspx <-- this one talks about conditional mode

http://www.asp.net/learn/ajax-videos/video-159.aspx

http://www.asp.net/learn/ajax-videos/video-118.aspx

Also, you can do it other way around and place an Updatepanel in your Content Holder, and set it to update based on the menu selection. This way only parts your need actually be updated in content holder.


hello.

hum, i'm not following: you're opening a new content page but you want to do that without refreshing the page presented in the browser? if that is what you want, then the answer is: cannot be done. you'll have to refactor your site so that the content is loaded through user controls. if that is not what you meant with the previous mail, please give us more information.


Luis Abreu:

hello.

hum, i'm not following: you're opening a new content page but you want to do that without refreshing the page presented in the browser? if that is what you want, then the answer is: cannot be done. you'll have to refactor your site so that the content is loaded through user controls. if that is not what you meant with the previous mail, please give us more information.

Ok.. let me try to explain it better for you..

Files:

Masterpage.master
Home.aspx
contact.aspx
services.aspx
portfolio.aspx

So all of the pages above use Masterpage.master as the master page The master page is layed like this

Top Image
Navi Bar
ContentPlaceHolder
Bottom Image

so lets say we start out at home.aspx and we want to click on the contact img (on the master page) and it goes to contact.aspx
i want to do it in a way that instead of loading contact.aspx and reloading the content of the masterpage.. it only loads the contentplace holder..

I understand what your saying but what controls would i have to use.. or maybe i set up the image the way its linked wrong i used html.. here is the code maybe i should do it another way? Now you have me really thinking.. ill tinker with it more later today but i greatly appreciate your help.. thanks


hello again.

ok, then it's option 1. i think that in this case, you'd need to refactor your site so that it only has one page. you'd need to transform home, contact, services and protofolio pages in asp.net user controls which would be loaded when you click on the menu. I've written an old post that shows how to replace the contents of an updatepanel. it might help you get starting:

http://msmvps.com/blogs/luisabreu/archive/2007/02/15/adding-controls-to-an-updatepanel-through-code.aspx


hey Luis.. ok i started using ascx and everything works fine except for the fact that now when i load a ascx file into a contentplaceholder in a updatepanel the asptreeview that i now have as a webcontrol instead of a page wont work... any ideas? it wont let me expand anything..

Saturday, March 24, 2012

Problem forcing an UpdatePanel to post from client-side code (javascript)...

Here's what I'm trying to achieve. I have a rather complex web page that allows data entry. The page utilizes Atlas UpdatePanels for partial reposts. When the user clicks on certain buttons, the data is validated (server-side), and then the user is given the option to save or abandon the changes. To do this, I use RegisterJavaScript to insert a client-side call to a javascript function which calls a vbscript function to display a msgbox (we're only using IE). The vbscript function returns the msgbox value back to the javascript function which then sets an ASP HiddenField. The next step is where I'm having problems. I need the javascript function to force a partial postback so that the server-side code can evaluate the msgbox results (in the hidden field), and respond accordingly. I don't want to repost the entire form because I loose data from other asynchronous client-side page modifications.

So the real question is; how can I force an UpdatePanel to post from client-side code? I've read a number of other threads on this subject and a suggested solution is to call the click event of a hidden LinkButton within the UpdatePanel. So I tried this and it worked! At least it worked for a while. This is the most frustrating part. At some point, and I have no idea what changed to cause this, the code stopped working. Now, when I call the click event, I get an undefined error in the doPostBack function and the form will no long post at all.

If anyone has any suggestions on what is causing this problem, or a better way to force an UpdatePanel to partial post, it would be greatly appreciated!

Here's some of my code;

<atlas:UpdatePanel ID="upConfirmActivitySave" runat="server" Mode="conditional"><ContentTemplate> <asp:HiddenField ID="hfConfirmActivitySave" runat="server" /> <asp:LinkButton ID="lnkDoPostBack" runat="server" style="display:none"></asp:LinkButton></ContentTemplate></atlas:UpdatePanel><script language="javascript" type="text/javascript"><!--function confirmActivitySave() { document.getElementById('hfConfirmActivitySave').value = ConfirmActivitySaveMsgbox(); document.getElementById('lnkDoPostBack').click();} // --></script><script language="vbscript" type="text/vbscript"><!--Function ConfirmActivitySaveMsgbox()'This only works for IEConfirmActivitySaveMsgbox = MsgBox("Do you wish to save?",35)End Function// --></script>

I decided to simplify things and created a new aspx page with a single UpdatePanel and two ASP ImageButtons, one inside the UpdatePanel and the other outside the UpdatePanel. The client-side code for the button outside the UP calls the click method for the button inside the UP. And sure enough, I get a partial post. So this tells me there's something wrong with my main project page. I wonder if I've hit some sort of atlas bug or limitation?


This just gets weirder and weirder. I restored my project to a prior version – one that the partial post code still worked. I compared the differences in the html between the working and non working versions and the only changes were some controls that were renamed (all within UpdatePanels) and a single control (an asp:HyperLink) that moved from outside to inside an UpdatePanel. So, from the working code, I moved the one control (using cut/past) and sure enough the page fails during the client-side partial post; "unknown runtime error". And get this; if I delete the control, the page still fails. By the way, all references to this control (client-side and server-side) have been removed. Essentially, the control is unused. But if I delete it, the page fails. What gives? I can remove other controls, or add and remove controls with no problem. It's almost like there's some reference that's not getting deleted correctly. Any ideas? Anyone?