[System.Web.Script.Services.ScriptMethod()]
[System.Web.Services.WebMethod]
public static List<string> lfromp(string id)
{
if (HttpContext.Current != null)
{
Page page = (Page)HttpContext.Current.Handler;
Label lbltxt = (Label)page.FindControl("lbltxt");
}
DataTable dt = new DataTable();
SqlConnection con = new SqlConnection("Data Source=logistics.jayom.org,1434;Initial Catalog=logistics_kl;Persist Security Info=True;User ID=kl_admin;[email protected]");
con.Open();
SqlCommand cmd = new SqlCommand("SPlgfpro", con); //select login from profile
cmd.CommandType = CommandType.StoredProcedure;
SqlParameter param;
param = new SqlParameter("@id", id);
param.DbType = DbType.String;
param.Direction = ParameterDirection.Input;
cmd.Parameters.Add(param);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
//dlstprofile.Items.Clear();
//for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
//{
// dlstprofile.Items.Add(ds.Tables[0].Rows[i][0].ToString());
//}
con.Close();
SqlCommand lfp = new SqlCommand("SPlgfpro");//select class from class
lfp.CommandType = CommandType.StoredProcedure;
lfp.Connection = con;
SqlParameter dpra;
dpra = new SqlParameter("@id", id);
dpra.Direction = ParameterDirection.Input;
dpra.DbType = DbType.String;
lfp.Parameters.Add(dpra);
con.Open();
lfp.ExecuteNonQuery();
SqlDataAdapter lda1 = new SqlDataAdapter(lfp);
DataSet dds1 = new DataSet();
lda1.Fill(dds1);
SqlDataReader drlp = lfp.ExecuteReader();
{
if (drlp.Read())
{
id = drlp["login"].ToString();
}
else
{
//if (HttpContext.Current != null)
//{
// Page page = (Page)HttpContext.Current.Handler;
// Label lbltxt = (Label)page.FindControl("lbltxt");
// lbltxt.Visible = true;
//}
}
con.Close();
}
List<string> emp = new List<string>();
return emp;
}
這是我cs
頁面和代碼運行正常,如果我不使用標籤,但我不能用在我的標籤我集可視性
[WEBMETHOD]
這裏lbltxt
是我的標籤,我想它設置爲可見的,如果我的條件不滿足
使用java腳本可見Lable成功後web方法 –
如何使用,你可以告訴我一個演示請 –
你的代碼返回一個字符串列表,這個方法不是一個webforms類型的調用。 – Steve