Showing posts with label type. Show all posts
Showing posts with label type. Show all posts

Monday, March 26, 2012

PageNavigator!

<div id="pageNavigator">
<input type="button" id="firstPageButton" value="<<" />
<input type="button" id="previousPageButton" value="<" />
<span id="pageIndexLabel"></span>
<span id="pageCountLabel"></span>
<input type="button" id="nextPageButton" value=">" />
<input type="button" id="lastPageButton" value=">>" />
</div>

I need to use image buttons for navigation and that works fine, but my question is how can I make certain image to change the src (to a disabled image) when it reaches either the very first page or very last page!

Please advice!

Hi,

supposed you've declared an image like:

<img id="myImage" src="http://pics.10026.com/?src=enabledImage.gif" alt="" />

then you can do it using pure Javascript:

if(firstPageReached || lastPageReached) {
document.getElementById('myImage').src = 'disabledImage.gif';
}

or Atlas:

var myImage = new Sys.UI.Control($('myImage'));
myImage.initialize();

if(firstPageReached || lastPageReached) {
myImage.set_imageURL('disabledImage.gif');
}

all understood, but how can I attach the event that it has reached the end of page or last of page?
Hi,

this really depends on how you have designed your PageNavigator (are you using server controls? Did you implement a client control?). If you need some info about how to raise events in the Atlas framework, please checkthis article.

below you will find my xml script. Please help me if you can!

<script type="text/xml-script">
<page xmlns:script="http://schemas.microsoft.com/xml-script/2005">
<components>
<listView id="CustomersResults" itemTemplateParentElementId="CustomersResults_itemTemplateParent" >
<layoutTemplate>
<template layoutElement="CustomersResults_layoutTemplate" />
</layoutTemplate>
<itemTemplate>
<template layoutElement="CustomersResults_itemTemplate">
<label id="CustomersResults_Name">
<bindings>
<binding dataPath="Name" property="text" />
</bindings>
</label>
<label id="CustomersResults_CustomerId">
<bindings>
<binding dataPath="CustomerId" property="text" />
</bindings>
</label>
<label id="CustomersResults_Description">
<bindings>
<binding dataPath="Description" property="text" />
</bindings>
</label>
<image id="CustomersResultsImageThumbPath">
<bindings>
<binding dataPath="CustomerID" property="imageURL" transform="DoAdditionalImageHandling" />
<binding dataPath="CustomerName" property="alternateText" />
</bindings>
<behaviors>
<hoverBehavior hover="ImageHandler" />
</behaviors>
</image>
</template>
</itemTemplate>
<bindings>
<binding dataContext="CustomersResultsview" dataPath="filteredData" property="data" />
</bindings>
</listView>
<dataView id="CustomersResultsview" pageSize="6">
</dataView>

<dataNavigator id="CustomersResultspageNavigator" dataView="CustomersResultsview"/>
<button id="CustomersResultspreviousPageButton" parent="CustomersResultspageNavigator" command="previousPage">
<bindings>
<binding property="enabled" dataPath="hasPreviousPage"/>
</bindings>
</button>
<label id="CustomersResultspageIndexLabel" parent="CustomersResultspageNavigator">
<bindings>
<binding property="text" dataPath="pageIndex" transform="Add"/>
</bindings>
</label>
<label id="CustomersResultspageCountLabel" parent="CustomersResultspageNavigator">
<bindings>
<binding property="text" dataPath="pageCount"/>
</bindings>
</label>
<button id="CustomersResultsnextPageButton" parent="CustomersResultspageNavigator" command="nextPAGE">
<bindings>
<binding property="enabled" dataPath="hasNextPage"/>
</bindings>
</button>
<button id="CustomersResultsfirstPageButton" parent="CustomersResultspageNavigator" command="FIRSTPage">
</button>
<button id="CustomersResultslastPageButton" parent="CustomersResultspageNavigator" command="lastpage">
</button>
</components>
<references>
</references>
</page>
</script>

Saturday, March 24, 2012

PageRequestManagerServerErrorException: HtmlTableBodySection cannot have children of type

i've been looking really hard for reason but couldn't find any. I really need help on this:
i have a page with a complex grid inside an update panel -
The grid is a repeater that contains an html table and inside the item template there is also a <tbody> tag that contains another repeater with an html table template.

Now it works great when running locally and on the test server wich is an win 2003 on the local network and it even ran ok on the previously hosted server but on the new one i get this error:
Sys.WebForms.PageRequestManagerServerErrorException: 'HtmlTableBodySection' cannot have children of type 'Repeater'.
and all i can find about this type of error is unrelated to the event in this case.

Can anyone suggest anything here?

ps. the only reason for the tbody is because i need a way to 'minimize' related rows (the rows of the inner repeater) in one click of parent row.

HtmlTableBodySection is a new type for .NET 2.0 SP1, so if you had the Service Pack installed than this should work

Wednesday, March 21, 2012

Parital Rendering using a DataList for Trigger

Lets say I have a DataList that describes the type of a widget. I want to use that DataList to populate a list of all widgets with that type.

<

atlas:ScriptManagerID="AtlasScriptManager1"EnablePartialRendering="true"runat="Server"/><asp:DataListid="dlWidget"runat="server"RepeatColumns="4"Width="100%"><ItemTemplate><asp:LinkButtonOnCommand="PickWidget"CommandArgument='<%# DataBinder.Eval(Container.DataItem,"TypeId") %>'id="cmdGenre"runat="server">

<%

#DataBinder.Eval(Container.DataItem,"Type") %></asp:LinkButton></ItemTemplate></asp:DataList>

Here is the repeater

<atlas:UpdatePanelID="atUpdateWidget"runat="server"><ContentTemplate><asp:Repeaterid="rptPickedWidget"runat="server"Visible="False"><ItemTemplate><tr>

<tdclass="trackListing"><%#DataBinder.Eval(Container.DataItem,"WidgetName") %></td></tr></ItemTemplate></asp:Repeater></ContentTemplate><Triggers><atlas:ControlValueTriggerControlID="rptPickedWidget"PropertyName="DataSource"/></Triggers></atlas:UpdatePanel>

I have tried several different triggers and no matter what I pick the entire page refreshes. I have verified the entire page refresh both by noting the progress bar in the browser and placing a JS alert message outside of the update panel. If I change my DataList to a DropDownList and then use the SelectedValue as the Trigger the Partial Render works just fine. However in my particular case using a DropDownList isn't viable due to the number of items that it would have to contain.

Has anybody had any experience with this setup?


hello.

i assume that you made a typo because you're using the ID of the repeater instead of the datalist.

ok, back to the problem:

1. attempt number one: put the ID of the datalist on the trigger

2. if 1 doesn't work ( i really don't remember how the datalist generates the HTML, but i'm assumign that it generates a table with the ID of the control), then besides putting the ID of the datalist on the trigger, you could also try to call the registerasyncpostbackcontrol (ScriptManager class) and pass it a reference to the datalist control

note that i haven't tried any of this; if it doesn't work, come back here and, if possible, post a demo page. thanks.


Actually I did mean to put the ID of the repeater my idea was to trigger the panel to update whenever the datasource for the repeater was changed. Each time an item in the datalist is pressed the datasource on the repeater gets changed so that it displays a new set of "widgets".

I did make a little progress (and then a little regress). I used the ItemDataBound event to create a trigger for each option in the datalist. When I first load the page I can click on any of the datalist linkbutton objects and the updater panel refreshes (without reloading the whole page). Once the page has been reloaded, any subsequent click causes a full refresh. It would appear that the trigger collection gets lost.

Also, I am having some problems with Javascript not working either. Everything works just dandy on a full page load, but it is a partial render I lose JS functionality.

I really like Atlas in general and the examples show it being a really cool tool, I am just having issues getting in to real life examples.


Sorry for the double post, but I can't seem to edit my posts.

http://test.bfrd.biz/

I have set up a demonstration of what I am hoping to accomplish.


hello.

hum...not sure on what you're doing here. from your previous posts, it seems like you want to get a partial update when you change an item from the datalist, ie, you want to refresh the repeater when you selec a new thing on the datalist control. if this is what you want, then you should wrap the repeater in an udpatepanel (you're already done this) and you should also set a trigger between the panel and the datalist control. no need to set it between the panel and repeater because all the event of the repeater the require a postback (ex.: clicking on a button placed inside the repeater) should give you an automatic partial postabck.


I added the source code (see links at the top) to my example of what I would like to have happen.

http://test.bfrd.biz/DataListType.aspx

You mentioned that I should use a DataList event to fire the update, but what type of DataList event would know that I clicked on a LinkButton inside its Item Template? I was binding directly (or at least trying) to the LinkButton contained within the DataList. Hopefully the source code will help identify my intentions more clearly.

Also, to re-iterate my current problem. When the page first loads (see link above) the user is presented with a JS alert message. This is just to signify that the entire page has loaded. The user is then presented with the Products for the first Category by default. If the user clicks on any of the items in the DataList the Repeater is refreshed and the page only updates partially (no JS alert message). This appears to be working as it should, however if the user then selects another Category the entire page loads and all subsequent Category Click events cause the entire page to load. It would appear that the Trigger Collection that I populated on the Initial Page Load is not maintained by the built-in State Control. Is there a way to do this, or am I stuck?

Thanks


hello again.

well, i'm not seeing your code. what i can tell you is that during the initial loading of the page, all the links are being correclty added to the async controls collection maintained in the pagerequestmanager client object. during a partial postback, it doesn't have the correct values. that's why you're getting a full postback. what are you doing only during the initial loading of the page?


Sorry to be unclear the code is at the top ofhttp://test.bfrd.biz/DataListType.aspx. I added them in as seperate links. The reason I only populate the DataList on the initial page load, was that I didn't see the reason in getting the list of Categories each time (it doesn't change that much).

hello.

well, you'll have to run the trigger code on all the postbacks. i guess that you might change your code slighlty so that you fo through all the rows of the datalist, find the button and run the code you've already got for creating a trigger.


Ok, I added a routine that Populates the Trigger collection everytime that the Repeater is populated. But once again, the routine works the first time and the stops working on subsequent tries.

http://test.bfrd.biz/DataListType.aspx

As always the current code is available by clicking the links at the top of the page.


hello again.

hum...i think i'm starting to see the problem. if you use fiddler (or another http sniffer) you'll see that you're not getting the correct values for the asyncpostbackcontrolsids property. can you send me a small sample (with the db) to my email to see if i get any idea on how to solve this?


The current code for both the dropdown and datalist examples can be found using the buttons at the bottom of each page. The database is the Northwind example database which I got when I installed SQL 2000. I will zip up the project and send it to you once I get to work. Could you please PM me a location to send to?

Thanks for all of your help.

P.S. At least I got the code viewer control to use Atlas like I wanted it to. :)


hello.

send it to labreu at gmail.com thanks


Did you find any solution to this problem?

hello.

well, i'm almos positive that i've received the sample and i've replied...i can't seem to recall what i've said though...

Parser Error Message: Type System.Web.UI.UpdatePanel does not have a public property named

Hi, first post...I am fairly new to ajax and was looking for some guidance on my problem. I installed the 3 files (Ajax 1.0 RC, Toolkit and the Futures December CTP). I wanted to convert an exsisting and working .net 2.0 sample aspx page into AJAX to learn how the updatepanels work. The page contains a bunch of datagrids that i wanted to place inside "updatepanels".

However, I keep getting the parser error"Type 'System.Web.UI.UpdatePanel' does not have a public property named 'datagrid'." whenever I placeanything inside the panels (table, div, tr...etc). I am sure its a pretty straight forward problem but not sure where to start looking.

If it matters, my solution in MS Visual Studio does not include a BIN folder. (something tells me i need it) I created a "New Website" and selected "AJAX-enabled website" and went from there. I could not find templates to start working from.

Thanks in advance!
Skimo!

<

asp:ScriptManagerID="ScriptManager1"runat="server"></asp:ScriptManager>

<asp:UpdatePanelID="UpdatePanel1"runat="server">

<

asp:datagridid="results"runat="server"GridLines="Horizontal"BorderWidth="2px"BorderColor="#f4f4f4"CellPadding="5"CellSpacing="0"AlternatingItemStyle-BackColor="#EAEAFF"ShowHeader="False"Width="100%"Autogeneratecolumns="False"AllowPaging="true"BorderStyle="Solid"PageSize="25"OnPageIndexChanged="results_Paging"><columns><asp:TemplateColumnItemStyle-Width="15%"><ItemTemplate>

<%

# DataBinder.Eval(Container.DataItem,"createdate") %></ItemTemplate></asp:TemplateColumn><asp:TemplateColumnItemStyle-Width="15%"><ItemTemplate>

<%

# DataBinder.Eval(Container.DataItem,"name") %></ItemTemplate></asp:TemplateColumn><asp:TemplateColumnItemStyle-Width="70%"><ItemTemplate>

<%

# DataBinder.Eval(Container.DataItem,"comment") %></ItemTemplate></asp:TemplateColumn>

</columns><PagerStyleMode="NumericPages"HorizontalAlign="Center"/>

</

asp:datagrid>

</

asp:UpdatePanel>

you cant load datagrid in the page.load when its inside of UpdatePanel.

This is because UpdatePanel gets call first before the grid gets load. Thats is why it couldnt find it.

you can have button inside of updatepanel, when you click the button the it will do databind with grid


It is indeed a straightforward problem. Everything inside an UpdatePanel goes inside a "ContentTemplate", like this:

<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:DataGrid ...>
</asp:DataGrid>
</ContentTemplate>
</asp:UpdatePanel>


Thank you so much!! I learned something :)

Does this mean I do not need to worry about the BIN folder not being there?

-Skimo


You won't need a bin folder to just use ASP.NET AJAX itself, since it gets installed globally for the machine.

If you use the AJAX Control Toolkit or the December Futures CTP, then your project will need to have the appropriate binaries in the bin folder.

I'm glad you're off and running... good luck exploring ASP.NET AJAX!


Great thanks for your help!

Skimo