有关 前台调用后台返回值的问题;
我现在在前台需要获得3个方法的返回值.能写成一个方法来获取吗,如果可以的话应该怎么写.
再问。可以写成一个类来到处调用吗。如果可以,应该怎么写。 谢谢!!!前台页面function load()
{
var aa= "<%=message()%>";
if(aa==1)
{
var info="<%=messageinfo() %>";
var url= "<%=url() %>";
}CS页面的方法
public int message()
{
ds = DBAcess.Select("select * from T_message where m_accpetid=1 and m_read=1");
int i = ds.Tables[0].Rows.Count;
if (i > 0)
{
return 1;
}
else
{
return 0;
} }
public string messageinfo()
{
ds = DBAcess.Select("select * from T_message where m_accpetid=1 and m_read=1");
string s = ds.Tables[0].Rows[0]["m_name"].ToString();
return s;
}
public string url()
{
ds = DBAcess.Select("select * from T_message where m_accpetid=1 and m_read=1");
string s = ds.Tables[0].Rows[0]["m_p_e_id"].ToString();
string type = ds.Tables[0].Rows[0]["m_type"].ToString();
string userid = ds.Tables[0].Rows[0]["m_accpetid"].ToString();
if (type == "11")//任务消息
{
string url = "ReadMessage.aspx?m_p_e_id=" + s + "&&m_type=" + type + "&&m_accpetid=" + userid;
return url;
}
else
{
string url = "looklist.aspx?m_p_e_id=" + s + "&&m_type=" + type + "&&m_accpetid=" + userid;
return url;
}
}
我现在在前台需要获得3个方法的返回值.能写成一个方法来获取吗,如果可以的话应该怎么写.
再问。可以写成一个类来到处调用吗。如果可以,应该怎么写。 谢谢!!!前台页面function load()
{
var aa= "<%=message()%>";
if(aa==1)
{
var info="<%=messageinfo() %>";
var url= "<%=url() %>";
}CS页面的方法
public int message()
{
ds = DBAcess.Select("select * from T_message where m_accpetid=1 and m_read=1");
int i = ds.Tables[0].Rows.Count;
if (i > 0)
{
return 1;
}
else
{
return 0;
} }
public string messageinfo()
{
ds = DBAcess.Select("select * from T_message where m_accpetid=1 and m_read=1");
string s = ds.Tables[0].Rows[0]["m_name"].ToString();
return s;
}
public string url()
{
ds = DBAcess.Select("select * from T_message where m_accpetid=1 and m_read=1");
string s = ds.Tables[0].Rows[0]["m_p_e_id"].ToString();
string type = ds.Tables[0].Rows[0]["m_type"].ToString();
string userid = ds.Tables[0].Rows[0]["m_accpetid"].ToString();
if (type == "11")//任务消息
{
string url = "ReadMessage.aspx?m_p_e_id=" + s + "&&m_type=" + type + "&&m_accpetid=" + userid;
return url;
}
else
{
string url = "looklist.aspx?m_p_e_id=" + s + "&&m_type=" + type + "&&m_accpetid=" + userid;
return url;
}
}
Page.DataBind();
}
<%=messageinfo() %>";
"<%=url() %>";
为什么一定要用方法能 用 message messageinfo url 3个public变量 赋前面不行吗?