Skip to main content

Posts

How To Call .net Webservice using Javascript

using System; using System.Web; using System.Web.Services; using System.Web.Services.Protocols; [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] publicclass Service : System.Web.Services.WebService { public Service () { //Uncomment the following line if using designed components //InitializeComponent(); } [WebMethod] publicstring HelloWorld(string strName) { return"Hello" +strName; } } <!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><htmlxmlns="http://www.w3.org/1999/xhtml"><head><title>Untitled Page</title><scripttype="text/javascript">function sendDataAsXML_SOAP() { var req_params = "", url = "", number = 0, type = ""; /* Configure Parameters */ url = "http://localhost/TestW…

Calling page methods from javascript using ASP.NET AJAX

We can call page methods (static methods declared in scope of asp.net page) using MS Ajax framework for ASP.NET. That is how can we do it : 1) Drop ScriptManager control on page 2) Set EnablePageMethods property of ScriptManager control to true 3) Add static public method in page-behind code (or its parent class) and mark it with [System.Web.Services.WebMethod] attribute: 4) add following javascript code to it <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %><!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><htmlxmlns="http://www.w3.org/1999/xhtml"><headrunat="server"><title>Untitled Page</title><scripttype="text/javascript">function CallMethod() { GetTime(); } function GetTime() { PageMethods.GetTime(GetTime…

How To Load xml string into DataSet

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" %><!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><htmlxmlns="http://www.w3.org/1999/xhtml"><headrunat="server"><title>Untitled Page</title></head><body><formid="form1"runat="server"><div><asp:GridViewID="GridView1"runat="server"></asp:GridView></div></form></body></html>using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; publicpartialclass Default3 : System.Web.UI.Page { protectedvoid Page_Load(object…

How to convert from XmlTextWriter to String?

publicstring CreateXML(string strAuth,string strTran,string strDL,string strCode,string strMsgCode,string strMessage) { string xmlString; StringWriter sw = new StringWriter(); XmlTextWriter writer = new XmlTextWriter(sw); // start writing! writer.WriteStartDocument(); writer.WriteStartElement("Result"); writer.WriteElementString("Authentication", strAuth); writer.WriteElementString("Transaction", strTran); writer.WriteElementString("DL", strDL); writer.WriteElementString("Code", strCode); writer.WriteElementString("MsgCode", strMsgCode); writer.WriteElementString("Msg", strMessage); writer.WriteEndElement(); //Write XML, and then flush the writer... writer.Flush(); //Return text from string writer... xmlString = sw.ToString(); //close the Objects writer.Close()…

Error: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.Asp Net SqlConnection

when we deal with huge amount of data, generally it may occur TIMEOUT problem... in those situations Take care of 3 things ( problem will be almost solved ) 1. put the connection timeout property in Connection string string connstring=" Data Source=localhost;User ID=sa; pwd=secret; Initial catalog=nothwind;connect timeout=900;"; 2. set the command timeout for the SqlCommand Object com.CommandTimeout=0; // this will makes Command to execute unlimited seconds 3. Now .... last but not the least... in the form unload function destroy the connection object conn.Dispose();

Using an XML file for your ASP.NET settings

A very common requirement for web applications is that they be configurable in an easy way. A lot of times it doesn't make sense to use a database to store some simple settings for your web site, especially if the application doesn't require one in the first place. There are a ton of ways to accomplish this task, but it seems to me that XML is perfectly suited for this problem. I don't mean to presume that it is better than other solutions but in case it fits the bill for your project, here is once way it can be used. check out this link

Two approaches to redirection in ASP.NET

Directing a user to another page or resource is a common aspect of a web application. The user may initiate the transfer to another page any number of ways, including clicking a button or link or selecting a value in a drop-down list. ASP.NET provides a few ways to move to different pages. Here's a look at these options, along with commentary on when you should use which approach.http://www.builderau.com.au/program/asp/soa/Two-approaches-to-redirection-in-ASP-NET/0,339028371,339292658,00.htm?feed=rss