Showing posts with label load. Show all posts
Showing posts with label load. Show all posts

Wednesday, March 28, 2012

Treating an ASCX control as independent

One huge disadvantage of the UpdatePanel control, IMHO, is that all of the Page life cycle reloads again.

I was wondering, when I just want to load a single control that has nothing to do with the rest of the stuff on the page, is this roundtrip really necessary?

I know that there's the client approach which says I can communicate with the server with minimal data and create all controls at the client-side, but that won't let me use server-controls and their benefits.

I thought of something that renders an ASCX control and serves its HTML, but it not covers everything, such as event firing.

Is my idea doable? Anyone bumped into this before?

Thanks!

If you want the benefits of the server controls you must also allow their life cycle to run. It's both the advantage and the disadvantage of the UpdatePanel.


Agreed... This is discussed here:http://encosia.com/index.php/2007/07/11/why-aspnet-ajax-updatepanels-are-dangerous

One option is to use ASP.NET PageMethods (also described in that link) which simplifies WebMethod calls and only returns results and not much overhead. You can also use multiple UpdatePanels so that you aren't refreshing so much.

Hope this helps,

-Damien

Monday, March 26, 2012

Trigger DynamicPopulate on page load

I currently have a page that takes a very long time to load. What I want is for the page to load up content-less (just the master page), and then have a UpdatePanel load the actual content dynamically instead of having a 3/4 second load time.

I've tried hiding the UpdatePanel and using a DynamicPopulate extender to set the UpdatePanel to visible, but I can't find a way to trigger the DynamicPopulate extender after the page load.

Has anyone got any ideas how I can do this?

Thanks,
Weiran.

weiranz:

What I want is for the page to load up content-less (just the master page), and then have a UpdatePanel load the actual content dynamically instead of having a 3/4 second load time.

We recently published two videos that address this very question.

How Do I: Implement the AJAX Incremental Page Display Pattern?

How Do I: Implement the Incremental Page Display Pattern using HTTP GET and POST?

Each video provides sample code in C# and Visual Basic. So you should be able to watch the videos, download the code, and achieve your goal of having the page dynamically load content.


I do have a followup questions on these examples:

Both examples use either a web service or a get/post to retrieve plain html which is filled into a div section. So the content is, even though dynamically populated, static. How would I trigger a dynamic populate of an update panel on page load? My scenario is the following:

I have a page that contains a search box with a button and a GridView in an UpdatePanel. The typical usage is that the user enters something in the textbox and clicks search, then the query will be executed and the updatepanel refreshed with the filled GridView, showing a progress indicator while working. This works very well...
Now I want to link to this particular page and pass in a search term via the querystring. Easy enough, in OnPageLoad I pickup the term(s) from the query string, execute the query and directly show the page with the filled GridView. This works, but may be bad if the query takes along time, the page will not show until the result is available. What I would like to do is to show the page and on page load doing a postback with the parameters passed in from the querystring.

Is there an easy way to kick off such a pseudo postback that does not trigger a full postback on page load?

Trigger load of usercontrol after page has rendered

Is there a way of triggering a usercontrol to load into an asp:placeholder right after the page has rendered to the screen, similar in the waywww.pageflakes.com does it.

I have a usercontrol that is quite slow to load up because it displays a graph that runs a chunky stored procedure. At the moment the whole page doesnt display until the user control has finished loading in.

Any way of doing this?

Anyone know a solution to this?
Please does anyone know?
might help...http://www.codeproject.com/Ajax/aspnetajaxtips.asp

Saturday, March 24, 2012

Trigger UpdatePanel after Page is loaded

HI, i was wondering if UpdatePanel could be trigger after the page is loaded.
Im trying to load a grid view inside an update panel without using any button event.

Thanks!

you could use a timer:

<asp:Timer ID="refreshTimer" runat="server" Interval="1000">
</asp:Timer>

<asp:UpdatePanel>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="refreshTimer" EventName="Tick" />
</Triggers>
</asp:UpdatePanel>

The update panel will be refreshed every 1 second, so you could decide what to show in it without any button events.


Thanks Yani for the reply, but using the timer will always refresh may updatepanel and this will create/increase server process a lot.

Still havent found a solution to my problems thru self coding. Looks like im going to use xmlhttp to load a div tag and put it inside an update panel so that when a year list box is changed it will reload the div content via javascript again.

Is there an alternative way in doing this?


Use Year select box(DropDownList) as an AsyncPostbackTrigger And put the Gridview inside update panel.


If I'm understanding correctly, you want to load the page initially with an empty UpdatePanel and then immediately do an async postback to load the contents of the UpdatePanel, right? (I assume this is because it takes a long time to load the data for that UpdatePanel.)

Check out my latest blog post:http://smarx.com/posts/delayed-load-with-an-updatepanel.aspx.

Wednesday, March 21, 2012

trouble with a simple scenario with Atlas(dependent dropdownlists)

Hi,

I have two dropdowns, for example states and counties.

When I change a state the right counties list should load in the counties dropdown.

It works fine with an updatepanel and a trigger to the States dropdown, until I add a "select from list" item and set AppendDataBoundItems=true. What happens is whenever I change the index of the first dropdown, the corresponding items are added to the second dropdown while it already has values from all the previous selections.

Is it possible to redraw the whole dropdown without add items from subsequent databinds?

Any suggestions would be welcome.

Thanks

hello.

can you show us a small page that reproduces the problem you're having? thanks.


Here is the code:

<

atlas:ScriptManagerID="s1"EnablePartialRendering="True"runat="server"EnableViewState="False"></atlas:ScriptManager><tablecellpadding="4"><tr><tdstyle="height: 73px"><asp:DropDownListID="ddlPosition"runat="server"AppendDataBoundItems="True"AutoPostBack="True"DataSourceID="dsPositions"DataTextField="PositionName"DataValueField="PositionID"><asp:ListItemValue="0">select from list</asp:ListItem></asp:DropDownList><asp:SqlDataSourceID="dsPositions"runat="server"ConnectionString="<%$ ConnectionStrings:conninfo %>"SelectCommand="Get_Positions"SelectCommandType="StoredProcedure"></asp:SqlDataSource></td><tdstyle="height: 73px"><atlas:UpdatePanelID="upStates"runat="server"EnableViewState="true"Mode="Conditional"><ContentTemplate><asp:DropDownListID="ddlStates"runat="server"AutoPostBack="True"DataSourceID="dsStates"DataTextField="StateName"DataValueField="StateID"AppendDataBoundItems="True"><asp:ListItemValue="0">select from list</asp:ListItem></asp:DropDownList><asp:SqlDataSourceID="dsStates"runat="server"ConnectionString="<%$ ConnectionStrings:conninfo %>"SelectCommand="Get_States_with_Jobs_by_Position"SelectCommandType="StoredProcedure"><SelectParameters><asp:ControlParameterControlID="ddlPosition"Name="PositionID"PropertyName="SelectedValue"Type="Int32"/></SelectParameters></asp:SqlDataSource></ContentTemplate><Triggers><atlas:ControlEventTriggerControlID="ddlPosition"EventName="SelectedIndexChanged"/></Triggers></atlas:UpdatePanel></td><tdstyle="height: 73px"><atlas:UpdatePanelID="upRegions"runat="server"Mode="Conditional"><ContentTemplate><asp:DropDownListID="ddlRegions"runat="server"AutoPostBack="True"DataSourceID="dsRegions"DataTextField="RegionName"DataValueField="RegionID"AppendDataBoundItems="True"><asp:ListItemValue="0">select from list</asp:ListItem></asp:DropDownList><asp:SqlDataSourceID="dsRegions"runat="server"ConnectionString="<%$ ConnectionStrings:conninfo %>"SelectCommand="Get_Regions_by_State_Position"SelectCommandType="StoredProcedure"><SelectParameters><asp:ControlParameterControlID="ddlPosition"Name="PositionID"PropertyName="SelectedValue"Type="Int32"/><asp:ControlParameterControlID="ddlStates"Name="StateID"PropertyName="SelectedValue"Type="Int32"/></SelectParameters></asp:SqlDataSource></ContentTemplate><Triggers><atlas:ControlEventTriggerControlID="ddlStates"EventName="SelectedIndexChanged"/></Triggers></atlas:UpdatePanel></td></tr><tr><tdcolspan="3"><atlas:UpdatePanelid="upGrid"runat="Server"Mode="Conditional"><ContentTemplate><asp:GridViewID="GridView1"runat="server"AllowSorting="True"AutoGenerateColumns="False"CellPadding="4"DataSourceID="dsJobs"ForeColor="#333333"GridLines="None"><FooterStyleBackColor="#5D7B9D"Font-Bold="True"ForeColor="White"/><Columns><asp:BoundFieldDataField="LocationName"HeaderText="LocationName"ReadOnly="True"SortExpression="LocationName"/></Columns><RowStyleBackColor="#F7F6F3"ForeColor="#333333"/><EditRowStyleBackColor="#999999"/><SelectedRowStyleBackColor="#E2DED6"Font-Bold="True"ForeColor="#333333"/><PagerStyleBackColor="#284775"ForeColor="White"HorizontalAlign="Center"/><HeaderStyleBackColor="#5D7B9D"Font-Bold="True"ForeColor="White"/><AlternatingRowStyleBackColor="White"ForeColor="#284775"/></asp:GridView><asp:SqlDataSourceID="dsJobs"runat="server"ConnectionString="<%$ ConnectionStrings:conninfo %>"SelectCommand="Get_Jobs_by_Regions"SelectCommandType="StoredProcedure"><SelectParameters><asp:ControlParameterControlID="ddlPosition"Name="PositionID"PropertyName="SelectedValue"Type="Int32"/><asp:ControlParameterControlID="ddlRegions"Name="RegionID"PropertyName="SelectedValue"Type="Int32"/></SelectParameters></asp:SqlDataSource></ContentTemplate><Triggers><atlas:ControlEventTriggerControlID="ddlRegions"EventName="SelectedIndexChanged"/></Triggers></atlas:UpdatePanel></td></tr></table>

any ideas?

thanks


hello.

well, presenting this kind of page will give few chances of getting an answer :(

can you build a demo page that doesn't use sqldatasource to get its data? for instance, use dummy arrays and bind them to the dropdowns a la ASP.NET 1.X...by doing this, you'll build a page that i and others (brighter than me) can simply copy and paste and run...then you'll probably get an answer.

thanks.


Does it work without the update panel?

You have this set "AppendDataBoundItems="True"which will cause this to happen - turn this off and it won't append it any longer.


You have to clear out all the items before you bind different data to them.

Use dropdownlist.items.clear()

You will have to readd any static items that you may want before databinding.