Showing posts with label dynamicservicemethod. Show all posts
Showing posts with label dynamicservicemethod. Show all posts

Saturday, March 24, 2012

ModalPopExtender DynamicServiceMethod with Master Page

If I place this in a <asp:content> on master page:

<asp:linkbutton runat="server" id="testLB" text="test" />
<atk:ModalPopupExtender runat="server" ID="mpuNotes" TargetControlID="testLB" PopupControlID="panmpu"
BackgroundCssClass="modalBackground" DropShadow="true" OkControlID="mpubutOk"
DynamicControlID="panNote" DynamicServiceMethod="GetNote">
</atk:ModalPopupExtender>
<asp:panel runat="server" id="panmpu" cssclass="modalPopup">
Davs
<asp:Panel runat="server" ID="panNote" />
<asp:Button runat="server" ID="mpubutOk" Text="Close" />
</asp:panel>

And the codefile looks like this:

[System.Web.Services.WebMethod]
public static string GetNote()
{
return "Hello - CodeFile";
}

The method is NOT called, but when moving it on a normal webform, it works. How to get it to work in a master page?


Looks like the ScriptService method is missing:http://blogs.msdn.com/sburke/archive/2006/10/21/hint-components-that-use-web-services-with-asp-net-ajax-v1-0-beta.aspx

Wednesday, March 21, 2012

ModalPopup - Web Service Failed - DynamicServiceMethod

I was trying to update the ModalPopup dynamically passing the topics section of an article to it.

I believe this is related to my DynamicServiceMethod. I test this out with C# and it worked fine, but would like to convert it to VB.

C# Code

<script runat="server">
[System.Web.Services.WebMethod()]
public static string GetContent(string contextKey)
{
string sIndName = contextKey;
return sIndName;
}
</script>

Method

VB CODE

<script runat="server">
<System.Web.Script.Services.ScriptMethod()> _
<System.Web.Services.WebMethod()> _
Public Function GetContent(ByVal contextKey) As String
Dim topics As String = contextKey
Return topics
End Function

</script>

This is the code

<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:v1ConnectionString %>"
SelectCommand="SELECT [TITLE], [TOPICS] FROM [AGEXPRESS]"></asp:SqlDataSource>
<asp:Repeater DataSourceID="SqlDataSource1" ID="Repeater1" runat="server">
<HeaderTemplate>
AG</HeaderTemplate>
<ItemTemplate>
<div class="title">
<asp:LinkButton ID="myLabel" Text='<%#Eval("TITLE") %>' runat="server"></asp:LinkButton>
<cc1:ModalPopupExtender

BackgroundCssClass="background"

DropShadow="true" EnableViewState="true"
PopupControlID="Panel2" CancelControlID="CancelButton" TargetControlID="myLabel"
ID="ModalPopupExtender" DynamicControlID="Label10" DynamicServiceMethod="GetContent"
DynamicContextKey='<%#Eval("TOPICS") %>' runat="server">
</cc1:ModalPopupExtender>
</div>
</ItemTemplate>
</asp:Repeater>
<asp:Panel ID="Panel2" runat="server" Width="300px" BackColor="BlanchedAlmond" BorderColor="Black">
<h2>
Topcis:</h2>
<asp:Label ID="Label10" runat="server" Text="Label"></asp:Label>
<div align="center">
<asp:LinkButton ID="CancelButton" runat="server">Close</asp:LinkButton>
</div>
</asp:Panel>
</form>

IF i don't find a solution then i can use the C#, but would really like this to be formatted in converted to VB (would be consistent with the site)

Please help.

You are missing the "Shared" keyword on the method. PageMethods are supposed to be Static/Shared.

Thanks! It worked.



Thanks it worked!

Hi

the property DynamicContextKey
what is useful?