Web service Problem

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
9/21/2010 5:52:20 AM
Gravatar
Total Posts 26

Web service Problem

hi Joe,

I placed a autocomplete extendar control,textbox and i defined  a web service method.. and i given the Servicepath,Service Method...but it is not working.. I already mentioned the path in layout.master

<asp:ScriptManager ID="ScriptManager1" EnablePageMethods="true" runat="server">
<Services>
<asp:ServiceReference Path="~/AutoComplete.asmx" />
</Services>
</asp:ScriptManager>

In Page.ascx

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
 

<asp:TextBox runat="server" ID="myTextBox" autocomplete="off" />
 

<ajaxToolkit:AutoCompleteExtender
runat="server"
ID="autoComplete1"
TargetControlID="myTextBox"
ServicePath="~/Autocomplete.asmx"
ServiceMethod="GetCompletionList"

MinimumPrefixLength="1"
CompletionInterval="1000"
EnableCaching="true"
CompletionSetCount="12" />


<asp:ImageButton ID="IBtnGo" runat="server" ImageUrl="~/images/go.gif"
CssClass="sys_go" onclick="IBtnGo_Click" style="height: 20px"/><br />


</ContentTemplate>
</asp:UpdatePanel>

In AutoComplete.asmx.cs

public string[] GetCompletionList(string prefixText, int count)
{
string con = ConfigurationManager.ConnectionStrings["ThinkBeyondCancerConnectionString"].ConnectionString;
string sql = "Select * from TBC_CancerType Where Title like @prefixText";
SqlDataAdapter da = new SqlDataAdapter(sql, con);
da.SelectCommand.Parameters.Add("@prefixText", SqlDbType.NVarChar, 100).Value = prefixText + "%";
DataTable dt = new DataTable();
da.Fill(dt);
string[] items = new string[dt.Rows.Count];
int i = 0;
foreach (DataRow dr in dt.Rows)
{
items.SetValue(dr["Title"].ToString(), i);
i++;
}
return items;
}

 

Please Provide The Solution

Thanks & Regards,

Ramakrishna Thota.

9/21/2010 7:00:20 AM
Gravatar
Total Posts 18439

Re: Web service Problem

Sorry, but you need to set breakpoints and use the debugger to see what is happening, find out if it is calling your service or not, I cannot debug it for you.

Best,

Joe

7/11/2012 4:44:49 PM
Gravatar
Total Posts 24

Re: Web service Problem

Joe,

I am trying to do something similar but with the jquery Autocomplete.

Using this tutorial:

http://www.codeproject.com/Articles/78704/3-Different-Approaches-for-Implementing-the-JQuery

I was able to get what I wanted to get working in a separate solution using a webservice serving up the data from a xml file on the server in JSON format and now I am attempting to make it into a module.

I am struggling getting the web service part to work.

When you implement a web service can it be in your custom module solution?  Will it be part of the UI.dll when it gets copied to the main solution bin?

As far as mojoportal goes what is your recommendation for implementing a web service that modules can consume?

Thanks Joe as always...

 

7/12/2012 12:47:13 PM
Gravatar
Total Posts 18439

Re: Web service Problem

Hi,

Yes the code would go in the UI project of your custom feature. However, if it needs any web.config stuff you would have to add that into the mojoPortal web.config file. I'm pretty sure with .svc type web services you need to declare the endpoints in web.config.

With .asmx type web service you may also need a web.config setting to declare the scripthandlerfactory, for use with ms ajax it would also require settings in scriptmanager but I think those wouldn't be needed for use with jquery

However, a simpler approach that could be done without any web.config settings would be to implement it as a generic handler (.ashx) which doesn't require endpoints declared in web.config but your js does of course need to know the url to the .ashx file.

You can see some example code for .ashx in mojoPortal source code in the Web/Services folder, we have some for CKeditor templates and TinyMCE templates return json.

Hope that helps,

Joe

7/23/2012 3:00:45 PM
Gravatar
Total Posts 24

Re: Web service Problem

Joe,

Worked great.

Here is the result

http://www.thefitgirls.com/calories-burned-calculator.aspx

Now I just want to figure out how to return what was clicked on button press and that way I can rate which entries are clicked the most.

The ashx handler works great and makes dealing with the jquery much easier.

Thanks as always,

This is the cheapest education you can buy.
Have a beer on me...

 

7/25/2012 8:28:27 AM
Gravatar
Total Posts 18439

Re: Web service Problem

Thanks for the beer!

Cheers,

Joe

You must sign in to post in the forums. This thread is closed to new posts.