Showing posts with label example. Show all posts
Showing posts with label example. Show all posts

Wednesday, March 28, 2012

pageLoad javascript function not being called

for some reason the javascript pageLoad method is not being called

the javascript is in scirbble.js

the example i have followed informs me that the pageLoad method should be ran when the atlas script manager control has loaded.

Is this corret.

Could someone please point me in the right direction for getting the below code to work

Below is the javascript and aspx code

function pageLoad()
{
var surface = document.getElementById("drawingSurface");
image = surface.getElementsByTagName("IMG")[0];
originalSrc = image.src;

surface.attachEvent("onmousedown", startStroke);
surface.attachEvent("onmouseup", endStroke);
surface.attachEvent("onmouseout", endStroke);
surface.attachEvent("onmousemove", addPoints);
}

form id="form1" runat="server">
<Atlas:ScriptManager ID="AtlasScriptManager" runat="server" >
<Services>
<Atlas:ServiceReference Path="ScribbleService.asmx" />
</Services>
<Scripts>
<Atlas:ScriptReference Path="ScriptLibrary\Scribble.js" />
</Scripts>
</Atlas:ScriptManager>
<div id="drawingSurface"
style="border:solid 1px black;height:200px;width:200px">
<img alt="Scribble" src="http://pics.10026.com/?src=ScribbleImage.ashx"
style="height:200px;width:200px" />
</div>
</form>

i have the same problem since the last release. I had pageLoad() methods which were able to set elements on the initial loading which no longer fire automatically :?(

As a workaround, you can attach to thePageRequestManager events like so :

<script type="text/javascript"> Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(pageLoad);</script>

when i do the above mentioned work around i get an error

'Sys.WebForms.PageRequestManager' is null or not an object

i have tried adding the script above and below the sript manager html elements but it makes no diffrence.

below is the aspx page

any help would glady be appreciated.

<headrunat="server">

<title>Atlas Scribble Sample</title>

</

head><body><formid="form1"runat="server"><Atlas:ScriptManagerID="AtlasScriptManager"runat="server"EnablePartialRendering=true><Services><Atlas:ServiceReferencePath="ScribbleService.asmx"/></Services><Scripts><Atlas:ScriptReferencePath="ScriptLibrary\Scribble.js"/></Scripts></Atlas:ScriptManager><divid="drawingSurface"style="border:solid 1px black;height:200px;width:200px"><imgalt="Scribble"src="ScribbleImage.ashx"style="height:200px;width:200px"/></div><scripttype="text/javascript">

Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(pageLoad);

</script></form>

</

body>

</

html>
throw an alert into your pageLoad() function to see if it's getting called; my guess is that it is, at least nothing you've posted here would prevent it. The issue I see is that the element 'surface' isn't going to respond to the attachEvent function as you have it written, at least not in this framework. You could try to us $addHandler(surface,'onmousedown',startStroke); instead.

PageMethod problem

HI. I have a problem with calling static PageMethod in asp.net ajax.

Problem apperars then i use UrlMappings. For example i have this code in web.config

<urlMappings>
<add url="~/ComputerManager/WorkstationList.aspx" mappedUrl="~/ComputerManager/ComputerList.aspx?comp_type=1"/>
<add url="~/ComputerManager/ServerList.aspx" mappedUrl="~/ComputerManager/ComputerList.aspx?comp_type=2"/>
</urlMappings>
and this code in ComputerList.aspx. cs
[WebMethod]
public static string SetSelection(string ID,string dataKey,bool state)
{
...
}

so, when call PageMethods.SetSelection(...) a have a error "The server method SetSelection is failed".

post url ends with WorkstationList.aspx/SetSelection

any ideas?

Hi,

You are rewriting your URL, and these URL are fixed one. They don't cater for any extra items or query string parameters. Thats why they don't map to actual page when you want to do that. In this case I will recommend that you add another entry with following items

<urlMappings><add url="~/ComputerManager/WorkstationList.aspx" mappedUrl="~/ComputerManager/ComputerList.aspx?comp_type=1"/><add url="~/ComputerManager/ServerList.aspx" mappedUrl="~/ComputerManager/ComputerList.aspx?comp_type=2"/><add url="~/ComputerManager/WorkstationList.aspx/SetSelection" mappedUrl="~/ComputerManager/ComputerList.aspx?comp_type=1"/><add url="~/ComputerManager/ServerList.aspx/SetSelection" mappedUrl="~/ComputerManager/ComputerList.aspx?comp_type=2"/></urlMappings>

Then i use mappings like you suggested, i get a request to pageComputerList.aspx with parametercomp_type=1, insted of calling PageMethod.

So i rewrite it this way

<urlMappings>
<add url="~/ComputerManager/WorkstationList.aspx" mappedUrl="~/ComputerManager/ComputerList.aspx?comp_type=1"/>
<add url="~/ComputerManager/ServerList.aspx" mappedUrl="~/ComputerManager/ComputerList.aspx?comp_type=2"/>
<add url="~/ComputerManager/WorkstationList.aspx/SetSelection" mappedUrl="~/ComputerManager/ComputerList.aspx/SetSelection"/>
<add url="~/ComputerManager/ServerList.aspx/SetSelection" mappedUrl="~/ComputerManager/ComputerList.aspx/SetSelection"/>
</urlMappings>

and that solves my problem.

Thanks for good idea,ziqbalbh.

Saturday, March 24, 2012

Paging and UpdatePanel

Hi,

If you look at this page you see an example of paging within an update panel which works well

http://mattberseth2.com/resizeable_gridview_columns/


The difference I have is I also have ajaxToolkit:HoverMenuExtender on my first column which popups 'Edit Details' text which takes you to a new page...

without any triggers on the updatepanel, my paging now works as the above example.. but when I use my hover menu and click on 'Edit Detail' I get the following error..


Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled. Details: Error parsing near '

to fix this error I use the following trigger on the updatepanel

<Triggers>
<asp:PostBackTrigger ControlID="GridView1" />
</Triggers>

now when I click on Edit Details it takes me to the new page as intended... but when I click on my paging buttons it doesnt work within the update panel it causes full page reload..

any ideas to get these two working together would be appreciated...


I have newver try that, I actually just added the GridView inside an UpdatePanel and seem to work really well


Hi,

Generally, I think implement it as Albert suggested should work.

If still not, please provide a simple repro that demonstrate the first problem(Sys.WebForms.PageRequestManagerParserErrorException: The messagereceived from the server could not be parsed. Common causes for thiserror are when the response is modified by calls to Response.Write(),response filters, HttpModules, or server trace is enabled. Details:Error parsing near ' ).


Hi,

simple repro.. would be to grab the example from the above link... and add following hovermenu to first column... add pagertemplate below...

paging works fine within the updatepanel

on clicking edit details you get the error as described in the first post...

to fix this error I use the following trigger on the updatepanel

<Triggers>
<asp:PostBackTrigger ControlID="GridView1" />
</Triggers>

but now the paging causes full page post back..

adding thelnkBtnRowEditDetail as a trigger as well dosent work as that gives a control id cant be found error.

 <asp:TemplateField ShowHeader="False"> <ItemTemplate> <asp:Panel CssClass="popupMenu" ID="PopupMenuCustomerName" runat="server"> <div class="popupMenuButtons"> <asp:LinkButton ID="lnkBtnRowEdit" SkinID="SmallTextPopUp" runat="server" CommandName="Edit" Text="Edit
</asp:LinkButton> <asp:LinkButton ID="lnkBtnRowEditDetail" SkinID="SmallTextPopUp" runat="server" CommandName="EditDetail" Text="Edit Detail"></asp:LinkButton> </div> </asp:Panel> <asp:Panel ID="PanelCustomerName" runat="server"> <asp:ImageButton ID="ImgButton" runat="server" AlternateText="Edit" ImageUrl="~/images/icon_edit.gif" CausesValidation="false" CommandName="" /> </asp:Panel> <ajaxToolkit:HoverMenuExtender ID="hme3" runat="Server" HoverCssClass="popupHover" PopupControlID="PopupMenuCustomerName" PopupPosition="Left" TargetControlID="PanelCustomerName" PopDelay="15"> </ajaxToolkit:HoverMenuExtender> </ItemTemplate> <EditItemTemplate> <asp:Panel CssClass="popupMenu" ID="PopupMenuCustomerName" runat="server"> <div class="popupMenuButtons"> <asp:LinkButton ID="lnkBtnRowUpdate" SkinID="SmallTextPopUp" runat="server" CommandName="Update" Text="Update"></asp:LinkButton><br /> <asp:LinkButton ID="lnkBtnRowCancel" SkinID="SmallTextPopUp" runat="server" CommandName="Cancel" Text="Cancel"></asp:LinkButton> </div> </asp:Panel> <asp:Panel ID="PanelCustomerName" runat="server"> <asp:ImageButton ID="ImgButton" runat="server" AlternateText="Update/Cancel" ImageUrl="~/images/icon_edit.gif" CausesValidation="false" CommandName="" /> </asp:Panel> <ajaxToolkit:HoverMenuExtender ID="hme3" runat="Server" HoverCssClass="popupHover" PopupControlID="PopupMenuCustomerName" PopupPosition="Left" TargetControlID="PanelCustomerName" PopDelay="15"> </ajaxToolkit:HoverMenuExtender> </EditItemTemplate> </asp:TemplateField>

 <PagerTemplate> <div class="item"> <div class="item_left"> <asp:Label ID="lblPageTxt" runat="server" SkinID="PageSmallText" EnableViewState="false" Text="Page" ></asp:Label> <asp:DropDownList ID="PageDropDownList" runat="server" AutoPostBack="true" OnSelectedIndexChanged="PageDropDownList_SelectedIndexChanged" /> <asp:Label ID="lblOfTxt" runat="server" SkinID="PageSmallText" EnableViewState="false" Text="of"></asp:Label> <asp:Label ID="lbTotalPages" runat="server" SkinID="PageSmallText"></asp:Label> </div> <div class="item_right"> <asp:ImageButton ID="imgbtnFirst" runat="server" CommandName="Page" CommandArgument="First" ImageUrl="~/images/arrow_up.gif"></asp:ImageButton> <asp:ImageButton ID="imgbtnPrev" runat="server" CommandName="Page" CommandArgument="Prev" ImageUrl="~/images/arrow_left.gif"></asp:ImageButton> <asp:ImageButton ID="imgbtnNext" runat="server" CommandName="Page" CommandArgument="Next" ImageUrl="~/images/arrow_right.gif"></asp:ImageButton> <asp:ImageButton ID="imgbtnLast" runat="server" CommandName="Page" CommandArgument="Last" ImageUrl="~/images/arrow_down.gif"></asp:ImageButton> </div> <div class="clear"></div> </div> </PagerTemplate>

not using the hovermenu isnt really an option... as this functionality is consistent with the rest of the site... unless you have another idea for reproducing this functionality

first column of our gridviews are a basic icon image... with a hover menu that has 'Edit' which edits gridview inline 'Edit Details' which goes to a new page ... they also have 'Clone' which provides a modal popup and 'Create Link'/'Remove Link' and other such functionlaity... which is available from the gridview using the hovermenu.



Would you mind showing a repro that I can run directly?


Hi Paul

I looked at the example at

http://mattberseth2.com/resizeable_gridview_columns/

and it looks great.
Can you share your code?

Thanks

Shalom


there is example code on that link... http://mattberseth2.com/resizeable_gridview_columns/

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>