I am trying to read the value of a field on a webpage from a static function in C# using AJAX. My question is: What is the line of code I must use in my C# part to read the data from an HTML input which has the runat="server" tag?
Here is the field:
<script>
function readfield() {
PageMethods.readfield(readfieldc);
}
function readfieldc(texte) {
alert(texte);
}
</script>
<asp:label id="myfield" runat="server" />
<input type="button" onclick="readfield()" value="submit" />
And the C# code:
[Webmethod()]
public static void readfield()
{
return Request["myfield"]; //This line is what I want to achieve
}
I actually have no idea of what code to use to do this
Help would be much appreciated.
Thank you
I ended up using JQuery serializeArray which does exactly that