asp.net中怎么将cs的局部变量的值传递给aspx页面上 30
后台cs代码:protectedvoidPage_Load(objectsender,EventArgse){SqlConnectionconn=newSqlConnec...
后台cs代码:
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=JCFJ;Integrated Security=True");//连接并实例化数据库
SqlCommand cmd = new SqlCommand("select * from TX ", conn);
SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
sda.Fill(ds, "TX");
DataTable dt = ds.Tables[0];
string xx = dt.Rows[1][2].ToString();
string XT = "uploads/" + xx;
}
前台aspx页面代码:
<div id="image">
<%
//定义要传递的参数,可通过数据库直接获取,按下列格式拼接完整,连接符为"|"
//string imgUrl = "images/1.jpg|images/2.jpg|images/3.jpg|images/4.jpg|images/5.jpg";
string imgUrl = "XT";
string imgLink =这里是超链接怕违规直接汉字了;
string imgTitle = "标题一|标题二|标题三|标题四|标题五";
//传递参数给JS代码,需要7个参数。图片路径、链接地址、图片标题、div的宽、高、标题文字的行高、div的ID
Response.Write("<script type='text/javascript'>default_GetXml('" + imgUrl + "','" + imgLink + "','" + imgTitle + "','380','260','18','image')</script>");
%>
</div>
怎么样才能将后台XT的值传递到 string imgUrl = "XT"; 江湖救急啊 各位大神帮帮忙 展开
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=JCFJ;Integrated Security=True");//连接并实例化数据库
SqlCommand cmd = new SqlCommand("select * from TX ", conn);
SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
sda.Fill(ds, "TX");
DataTable dt = ds.Tables[0];
string xx = dt.Rows[1][2].ToString();
string XT = "uploads/" + xx;
}
前台aspx页面代码:
<div id="image">
<%
//定义要传递的参数,可通过数据库直接获取,按下列格式拼接完整,连接符为"|"
//string imgUrl = "images/1.jpg|images/2.jpg|images/3.jpg|images/4.jpg|images/5.jpg";
string imgUrl = "XT";
string imgLink =这里是超链接怕违规直接汉字了;
string imgTitle = "标题一|标题二|标题三|标题四|标题五";
//传递参数给JS代码,需要7个参数。图片路径、链接地址、图片标题、div的宽、高、标题文字的行高、div的ID
Response.Write("<script type='text/javascript'>default_GetXml('" + imgUrl + "','" + imgLink + "','" + imgTitle + "','380','260','18','image')</script>");
%>
</div>
怎么样才能将后台XT的值传递到 string imgUrl = "XT"; 江湖救急啊 各位大神帮帮忙 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询