Showing posts with label custom. Show all posts
Showing posts with label custom. Show all posts

Monday, March 26, 2012

Instantiate Accordion content

Hi,

I have an accordion with some panes that have custom controls in their content templates.

The accordion is NOT databound ... the contents are static, though viewstate is helping keep track of the values in the custom controls.

When the page is created for the very first time, NOT postback, the accordion panes do not instantiate the user controls until sometime during the OnPreRender stage in the lifecycle.

On subsequent postbacks however, the accordion panes do instantiate their controls during the LoadState stage, due to their presence in ViewState.

How can I make the accordion panes instantiate their content templates earlier than OnPreRender when the page is created for the first time?

The accordion pane's content templates are not dynamic. They are coded into the page markup.

I have tried calling something like Accordion.Panes[0].Content.InstantiateIn(Accordion.Panes[0]) and various combinations at various stages, but I usually ended up just getting duplicate versions of the controls in the wrong places in the page!

I could not find any "EnsureControls()" methods available in the accordion.

Many thanks in advance for your helpful suggestions,

Ben

Hi,
Accordion.Panes[0].FindControl('nothing') will make pane 0 to instantiate its templates. FindControl is an indirect way to call EnsureChildControls.

-yuriy
http://couldbedone.blogspot.com


Yuriy! Thank you so much! I'm relieved!

Wednesday, March 21, 2012

Is it possible to catch a GetPostBackEventRefrence in an UpdatePanel?

I've got a custom gridview control where inside the RowDataBound event, I am setting an attribute to the row to allow the user to just click anywhere on the row, instead of clicking the 'Select' command.

This works fine, but it does a postback. Is it possible to capture that in the updatepanel?


e.Row.Attributes.Add("onclick", Page.ClientScript.GetPostBackEventReference(this, "Select$" + e.Row.RowIndex.ToString()));

There should be no difference in behavior whether you're in an UpdatePanel or not. The only constraint I can think of is that you can't alter anything that isn't contained in an UpdatePanel during the PostBack.

So, if you can catch the GetPostBackEventReference normally, you should still be good in an UpdatePanel.


I have the same problem. It works perfectly without the updatepanel, but when the gridview is placed inside the update panel, it does not update when the user clicks the row.


Hi,gidikh

To troubleshoot this issue, we really need the source code to reproduce the problem, so that we can investigate the issue in house. It is not necessary that you send out the complete source of your project. We just need a simplest sample to reproduce the problem. You can remove any confidential information or business logic from it.

Thanks


I figured out my problem. I was updating a formview outside of the updatepanel. As soon as I put that formview into an updatepanel of it's own, everything worked as it should.