Saturday, March 24, 2012

AJAX and Master pages

hi all,

I try AJAX with master pages and I've stucked in some probelm. Accroding to my requirement, my master page has two contentplacehoder.One on left side, and one in the middle. I have an update panel in the middle content place holder. Now I want to update the control in the middle contentplace holder on trigger click event of some Image button which is in the left contetplace holder. I've put my scriptmanager in the master page also.

But when I click the Image button,entire master page is doin a postback,which Is not AJAX. Can some tell me how to achive this.

I've seen the standard example of updatpanel with master pages in documentation, but there the button is actually on the master page. But in my situation, I've a button in some other contentplace holder, on whose click event I want to update my panel, without postback.

I really don't understand why the post back is hapening. HOw can I approach to solve this problem. can some please help me. Its kind of urgent.

Thanks a lot.

Hello,

First of all a little advise, never use (learn) a new thing, when something is urgent... :-)

Its a bit difficult to answer without a code example from your side, but i try.
The problem i think what is giving the postback, is that you use different aspx pages in your content holders, and only the middle one has a UpdatePanel, but the left one doesn't.
So the click on the button in the left content holder, act normal inside his own aspx page, and causes the masterpage to do a postback..

The problem like you have can maybe solved (just in theory), by putting the buttons also in a update panel, en doing a codebehind refresh of the update panel in the middle.

Like i said, i didn't tried this myself, but maybe gives you some direction where to go.

Marchu


Wrap everything (starting with masterpage before the contentplacholders) with a updatepanel.

add a updatepanel to both of the contentplaceholders...

This way when you have a change that happens in one that updates the other the encapulating updatepanel will update what is required...(it should work in theory at least and a technique I use for handling modalspopups within a gridview but in seperate panels


Hi Marchu,

First of all thanks for your immediate reply. And sorry for one small thing, I forgot to mention in my (long) post above, that my button and updatepanel are in same content page(aspx page). Just that I've put the button in another content place holder then my update panel. When that page is called in the master page, the button comes in the lesft contentplace holder, and update panel in the middle. Thats why I assumed that it will work and will not give post back.

I hope u got my point. I was not able to put the code as I'm not at my work place, and its lying there. I'll try to put it in my next post if possible. ( sorry for that). What do you suggest about this. Shhould still try with putting the button also in the update panel?

Thanks again.


Hey thakns a lot Jody.

I'll try Marchu and yours both way and get back to you if any issues or problems.

Thanks a lot again.....


Let us know what works for you - we are here for ya...

Hello,

yes i think you can better try that, or the solution from jodywbcb.

On the other hand, i know for sure when you post some code.
(To be honest, its not 100% clear what you mean :-))

Marchu


Hi Marchu and Jodywbcb,

Thanks a lot for reply first. Well, as you both told, I tried the same thing by keeping the butttons and everything in the update panel and everything works.I did it as follows...

My mater page is same with two content place holder,one at left and one in middle. and my Scriptmanager is in master page.

In my content page, I've kep my repeater control, which should change on click of an Image button, inside an update panel, and this goes in the middle contenplacehoder of the master page.

Also I've kept my Image button too inside the update panel, and this goes for the left contenpalceholder of the master page. I've not used any triggers.

I tried to use only one updatepanel by encapsulating both the <asp:content></asp:content> but it gives an error.

Anyway thanks again and sorry for replying late as I was traveling and not at my office.

-Regards,

MehulMistry

No comments:

Post a Comment