Showing posts with label webpage. Show all posts
Showing posts with label webpage. Show all posts

Wednesday, March 28, 2012

Page.RegisterClientScriptBlock breaks Ajax?

Hi -

I am using

Page.RegisterClientScriptBlock to write a script dynamically to my webpage. For some reason, this seems to break some of my other java script (don't get called at all).

I'd be grateful for any idea experience with this!!! Thanks!!!!

Oliver

You want to use the ScriptManager version of that same method instead, the Page's version doesn't work withthe ajax framework.


Paul -

thanks so much. This was quite useful. May I ask you a follow-up question? While Ajax now works on the page, one additional control that loads its Javascript from a file still doesn't ... is there anything special I need to consider?

Thanks again,

Oliver


Well, if that control doesn't load the file through the scriptmanager, that'll be a problem for you as well. What's the control? Also, any .js files need to have a line at the end of them:

if(Sys && Sys.Application)
Sys.Application.notifyScriptLoaded();

Saturday, March 24, 2012

Paging using DataGrid and DataList (referring to ScottGus paging tutorial)

I have a webpage that uses a Datalist adapted from ScottGu's example athttp://weblogs.asp.net/scottgu/archive/2006/01/07/434787.aspx. It does not seem to benefit from Ajax partial updates (update panel), since as it pages, it actually asks for different pages' urls, etc...(Please see ScottGu's fantastic tutorial there for more details).

Question: If I use a DataGrid that has paging turned on, will it (magically) perform the operations mentioned in Scott's article, that is, sending only that data through each page request that is pertinet to that page?

Question 2 There is a slim chance that ASP.Net Ajax is actually so smart as to do what I said above, however, I need a DataList (for formatting reasons) that does not have paging .

Is there a way for the paging mentioned in ScottGu's article to be applied to the asynchornous paging, and for the paging control on the page (a hyperlink) to fetch data from that stored "stash"?

Thanks,

Paolo

Dogs Rule!

Just glancing through Scott's post, it doesn't look like this will "just work" inside an UpdatePanel, because as you mention, it's requesting a new page URL with the page number in the query string.

To get something like this to work, you'd need to first convert it to use postbacks instead of page navigation. (So change the hyperlink to a HyperLinkButton and pass the page number as an argument to the event handler instead of as a query string parameter.)

Basically, if you have a page that works with postbacks, it should be easy to use UpdatePanels to get AJAX functionality. If you have navigation, however (new URLs), then the UpdatePanel won't help you.


View this code

CODE
Sub BindData()
Dim mydt As New yourdatable()
Dim tba As NewyourobjectTableAdapters.yourtableadaper()


tba.Fill(mydt, Me
dgPager.CurrentPageIndex * Me.dgPager.PageSize , Me.dgPager.PageSize)

Me.dgPager.VirtualItemCount = yourqueryrecordcount

Me.
dgPager.DataSource = mydt
Me.
dgPager.DataBind()

Me.DataList1.DataSource = mydt
Me.DataList1.DataBind()

End Sub

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
If Not Page.IsPostBack Then
BindData()

End If
End Sub

Protected Sub dgPager_ItemCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs)
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
e.Item.Visible = False
End If

End Sub

ProtectedSub dgPager_PageIndexChanged(ByVal source As Object, ByVal e AsSystem.Web.UI.WebControls.DataGridPageChangedEventArgs)
Me.dgPager.CurrentPageIndex = e.NewPageIndex
BindData()

End Sub
ASPX page

<form id="form1" runat="server">
<asp:DataList ID="DataList1" runat="server" RepeatColumns="4" RepeatDirection="Horizontal">
<ItemTemplate>
<%# Eval("YourDataField") %><br />
</ItemTemplate>
</asp:DataList>
<asp:DataGridID="dgPager" runat="server" AllowPaging="True"AutoGenerateColumns="False" GridLines="None" PageSize="8"ShowHeader="False" OnPageIndexChanged="dgPager_PageIndexChanged"OnItemCreated="dgPager_ItemCreated" AllowCustomPaging="True">
<PagerStyle Mode="NumericPages" />
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>

</form>

Wednesday, March 21, 2012

partial Display of CalendarExtend Control

I am using CalendarExtend control on one of my webpage but for some reason it's not displayed correctly. When I click on imageButton to popup calendar control it display under textbox but It's partially displayed (missing Thursday,Fri, Sat).

All the below code is inside Table.

<asp:TextBoxID="txtPartNumber"runat="server"Width="181px"></asp:TextBox>
<imgsrc="Images/Calendar.png"alt="Calendar"id="ImgPartNumber"/>
<cc1:CalendarExtenderAnimated="true"CssClass="MyCalendar"ID="CEInstallationDate"PopupButtonID="ImgPartNumber"TargetControlID="txtPartNumber"runat="server">
</cc1:CalendarExtender>

.MyCalendar.ajax__calendar_container {
border:1pxsolid#646464;
filter:progid:DXImageTransform.Microsoft.Gradient(gradientType=0,startColorStr='steelblue',endColorStr='white');
color:blue;
width:250px;
}

Hi Bhavin,

I have tested your sample on my machine.It works pretty well on IE7 and on Firefox DXImageTransform.Microsoft.Gradient doesn't work but the issue you described above doesn't appear.

So I suspect that maybe your issue is caused on your system environment. Please upgrate your Ajax Control Toolkit to V10618 or V10920.

Hope this help.

Best regards,

Jonathan