Showing posts with label service. Show all posts
Showing posts with label service. Show all posts

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?

Modalpopup - Web Service Call Failed

My web service works great when I call it outside of the modalpopupextender. However, I can't seem to access the asmx page at all when using the modalpopup dynamic properties. I keep receiving errors stating both "web service call failed: 12030" & "web service call failed: 500" randomly. What am I missing here? Any help you can lend to my problem would be greatly appreciated!

<ajaxToolkit:ToolkitScriptManagerID="ScriptManager1"runat="server">
<Services>
<asp:ServiceReferencepath="~/GetCity.asmx"/>
</Services>
</ajaxToolkit:ToolkitScriptManager>

<asp:GridViewID="GridView1"runat="server"DataKeyNames="FILENAME"AutoGenerateSelectButton="True">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:linkButtonID="hlnkOrders"runat="server">Selectlnk</asp:linkButton>
<ajaxToolkit:ModalPopupExtenderID="ModalPopupExtender3"runat="server"
OKControlID="btnOK"
PopupControlID="Panel3"
TargetControlID="hlnkOrders"
DynamicServicePath="GetCity.asmx"
DynamicServiceMethod="LookupCityCode"
DynamicControlID="lblhidden"
DynamicContextKey='<%=eval("FILENAME") %>'
BackgroundCssClass="modal"
DropShadow="true">
</ajaxToolkit:ModalPopupExtender>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<AlternatingRowStyleBackColor="#FFFFC0"BorderColor="#004000"BorderWidth="1px"/>
</asp:GridView>

<asp:Panelrunat="server"ID="Panel3"BackColor="AliceBlue">
<asp:LabelID="lblHidden"runat="server"></asp:Label><br/><br/>
<asp:Buttonrunat="server"ID="btnOK"Text="OK"/>
</asp:Panel>

Imports System.Web.Script.Services.ScriptServiceAttribute
Imports System.Web.Script.Services.ScriptMethodAttribute

<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
PublicClass GetCity

Inherits System.Web.Services.WebService

Private strUserNameAsString =""
Private strServerNameAsString =""
Private strPasswordAsString =""
Private wAttachmentPathAsString =""

<WebMethod()> _
PublicFunction LookupCityCode(ByVal contextKeyAsString)AsString

'do some stuff
ReadExcelOrder(wattachmentPath & contextKey)
LoadParameters()

End Function

PrivateFunction ReadExcelOrder(ByVal FileNameAsString)AsString

'do some stuff

End Function

PrivateSub LoadParameters()

'do some stuff

End Sub

I'll answer my own question here. Once I added the property System.Web.Script.Services.ScriptService to the webservice, it works!

<WebService(Namespace:="http://tempuri.org/")> _
<System.Web.Script.Services.ScriptService()> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
PublicClass GetCity


Even after adding


[System.Web.Script.Services.ScriptService]


 to my service it is not working. Please help