I have this function:
[System.Web.Services.WebMethod]
public static string EditPage(string nodeID)
{
DataTable dt = new DataTable();
using (SqlConnection con = new SqlConnection(Global.conString))
using (SqlCommand cmd = new SqlCommand("contentPageGetDetail", con))
{
cmd.Parameters.Add("@ID", SqlDbType.UniqueIdentifier).Value = Global.SafeSqlLiteral(nodeID, 1);
cmd.CommandType = CommandType.StoredProcedure;
cmd.ExecuteNonQuery();
using (SqlDataAdapter da = new SqlDataAdapter(cmd))
{
da.Fill(dt);
}
}
return nodeID;
}
I want to grab variables such as:
<asp:HiddenField ID="hfNodeID" runat="server" />
or
<asp:RadioButtonList id="rblContentTypesGetAll" OnLoad="rblContentTypesGetAll_Load" runat="server" >
</asp:RadioButtonList>
in my Web Form but When I try to reference their IDs they don’t auto complete and can’t be found. What am I missing? Is it even possible?
The WebMethod is static – it will not have access to the form controls. They’re not executed in the context of the page – you’ll need to get the required values using client side scripting and pass them in.