Quantcast
Channel: WCF, ASMX and other Web Services
Viewing all articles
Browse latest Browse all 555

How to gain access to Label1.Text in WebMethod section code ?

$
0
0

On aspx I have this

function ShowCurrentTime() {$.ajax({
        type: "POST",
        url: "JSFireCSharp.aspx/GetCurrentTime",
        data: '{name: "' + $("#<%=txtUserName.ClientID%>")[0].value + '" }',
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: OnSuccess,
        failure: function(response) {
            alert(response.d);
        }
    });
}

Then I have this in code behind

[System.Web.Services.WebMethod]
public static string GetCurrentTime(string name)
{
    return "Hello " + name + Environment.NewLine + "The Current Time is: "+ DateTime.Now.ToString();

(((Here I want to add a line Label1.Text = name but get error))))
}


I want to add a line Label1.Text = name but get error. It seems I am not able to gain access to Label1.
Pls help. What can I do ? Thanks
   


Viewing all articles
Browse latest Browse all 555

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>