变量绑定一段JS代码显示滚动图片,图片路径和图片标题是从数据库读取出来的,页面上用<%= image%>显示的 ,image是我定义的变量, 具体代码 /// <summary>
/// 绑定滚动图片
/// </summary>
/// <returns></returns>
public string GetImage()
{
int i = 0;
bigImage += "<script>";
List<News> list = NewsManage.SearchTOP4NewsInfo(1);
foreach (News news in list)
{
i++;
if (i == 1)
{
bigImage += " imgUrl1='" + news.Nimage + "';";
bigImage += " imgtext1='" + news.Ntitle + "';";
bigImage += " imgLink1=escape('#');";
}
if (i == 2)
{
bigImage += " imgUrl2='" + news.Nimage + "';";
bigImage += " imgtext2='" + news.Ntitle + "';";
bigImage += " imgLink2=escape('#');";
}
if (i == 3)
{
bigImage += " imgUrl3='" + news.Nimage + "';";
bigImage += " imgtext3='" + news.Ntitle + "';";
bigImage += " imgLink3=escape('#');";
}
if (i == 4)
{
bigImage += " imgUrl4='" + news.Nimage + "';";
bigImage += " imgtext4='" + news.Ntitle + "';";
bigImage += " imgLink4=escape('#');";
} }
bigImage += " var focus_width=512;";
bigImage += " var focus_height=194;";
bigImage += " var text_height=20;";
bigImage += " var swf_height = focus_height+text_height;";
bigImage += " var pics=imgUrl1+'|'+imgUrl2+'|'+imgUrl3+'|'+imgUrl4;";
bigImage += " var links=imgLink1+'|'+imgLink2+'|'+imgLink3+'|'+imgLink4;";
bigImage += " var texts=imgtext1+'|'+imgtext2+'|'+imgtext3+'|'+imgtext4;"; bigImage += "document.write('<object classid=clsid:d27cdb6e-ae6d-11cf-96b8-444553540000 codebase=http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0 width='+ focus_width +' height='+ swf_height +'>');";
bigImage += "document.write('<param name=allowScriptAccess value=sameDomain><param name=movie value=images/focus1.swf><param name=quality value=high><param name=bgcolor value=#F0F0F0>');";
bigImage += "document.write('<param name=menu value=false><param name=wmode value=opaque>');";
bigImage += "document.write('<param name=FlashVars value=pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'>');";
//bigImage += "document.write.('<embed src=focus2.swf quality=high pluginspage=http://www.macromedia.com/go/getflashplayer type=application/x-shockwave-flash width='+ focus_width +' height='+ swf_height +' FlashVars=pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'></embed>';";
bigImage += "document.write('</object>');";
bigImage += "</script>";
return bigImage;
}
最后这个方法的返回值赋给iamge变量。
页面上还有这些代码
<input type="text" class="text_1" runat="server" id="txtGuestEmail" name="txtGuestEmail"
value="请输入Email" onblur="verifyAddress();" onfocus="myFocus()" />
<input type="button" value="获取" class="btn_1" causesvalidation="false" runat="server" id="Button1" name="Button1"
onserverclick="Button1_ServerClick" />当点击按钮时 变量绑定的数据不能显示了,就是开始在页面加载时 我已经给变量绑定了数据。 我在执行按钮点击事件时,又重新绑定了数据,如:
protected void Button1_ServerClick(object sender, EventArgs e)
{
string email = txtGuestEmail.Value;
GuestRelation relation = new GuestRelation();
relation.GrEmail = email;
relation.GrState = "未回复";
int i = GuestRelationManage.InsertGuestRelation(relation);
if (email.Length == 0)
{
Page.RegisterStartupScript("1", "<script>alert('邮件不为空!');</script>");
DataBindCompany();
DataBindNotice();
ViewState["image"] = GetImage();
image = (string)ViewState["image"];
}
else if (email.Trim() == "请输入Email")
{
GetImage();
ScriptManager.RegisterStartupScript(Button1, this.GetType(), "warning",
"alert('未输入邮件地址!')", true);
ViewState["image"] = GetImage();
image = (string)ViewState["image"];
DataBindCompany();
DataBindNotice();
}
else
{
if (i > 0)
{
GetImage();
ScriptManager.RegisterStartupScript(Button1, this.GetType(), "warning",
"alert('信息发送成功!')", true);
DataBindCompany();
DataBindNotice();
ViewState["image"] = GetImage();
image = (string)ViewState["image"];
this.txtGuestEmail.Value = "请输入Email";
}
else
{
ScriptManager.RegisterStartupScript(Button1, this.GetType(), "warning",
"alert('信息发送失败!请与管理员联系!')", true);
DataBindCompany();
DataBindNotice();
ViewState["image"] = GetImage();
image = (string)ViewState["image"];
}
}
}
当执行点击事件弹出提示框时,页面滚动图片不滚动了, 查看源文件,又能看来用变量绑定的数据,
这是怎么回事啊? 急啊 谢谢各位高手了 谢谢 非常谢谢....
/// 绑定滚动图片
/// </summary>
/// <returns></returns>
public string GetImage()
{
int i = 0;
bigImage += "<script>";
List<News> list = NewsManage.SearchTOP4NewsInfo(1);
foreach (News news in list)
{
i++;
if (i == 1)
{
bigImage += " imgUrl1='" + news.Nimage + "';";
bigImage += " imgtext1='" + news.Ntitle + "';";
bigImage += " imgLink1=escape('#');";
}
if (i == 2)
{
bigImage += " imgUrl2='" + news.Nimage + "';";
bigImage += " imgtext2='" + news.Ntitle + "';";
bigImage += " imgLink2=escape('#');";
}
if (i == 3)
{
bigImage += " imgUrl3='" + news.Nimage + "';";
bigImage += " imgtext3='" + news.Ntitle + "';";
bigImage += " imgLink3=escape('#');";
}
if (i == 4)
{
bigImage += " imgUrl4='" + news.Nimage + "';";
bigImage += " imgtext4='" + news.Ntitle + "';";
bigImage += " imgLink4=escape('#');";
} }
bigImage += " var focus_width=512;";
bigImage += " var focus_height=194;";
bigImage += " var text_height=20;";
bigImage += " var swf_height = focus_height+text_height;";
bigImage += " var pics=imgUrl1+'|'+imgUrl2+'|'+imgUrl3+'|'+imgUrl4;";
bigImage += " var links=imgLink1+'|'+imgLink2+'|'+imgLink3+'|'+imgLink4;";
bigImage += " var texts=imgtext1+'|'+imgtext2+'|'+imgtext3+'|'+imgtext4;"; bigImage += "document.write('<object classid=clsid:d27cdb6e-ae6d-11cf-96b8-444553540000 codebase=http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0 width='+ focus_width +' height='+ swf_height +'>');";
bigImage += "document.write('<param name=allowScriptAccess value=sameDomain><param name=movie value=images/focus1.swf><param name=quality value=high><param name=bgcolor value=#F0F0F0>');";
bigImage += "document.write('<param name=menu value=false><param name=wmode value=opaque>');";
bigImage += "document.write('<param name=FlashVars value=pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'>');";
//bigImage += "document.write.('<embed src=focus2.swf quality=high pluginspage=http://www.macromedia.com/go/getflashplayer type=application/x-shockwave-flash width='+ focus_width +' height='+ swf_height +' FlashVars=pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'></embed>';";
bigImage += "document.write('</object>');";
bigImage += "</script>";
return bigImage;
}
最后这个方法的返回值赋给iamge变量。
页面上还有这些代码
<input type="text" class="text_1" runat="server" id="txtGuestEmail" name="txtGuestEmail"
value="请输入Email" onblur="verifyAddress();" onfocus="myFocus()" />
<input type="button" value="获取" class="btn_1" causesvalidation="false" runat="server" id="Button1" name="Button1"
onserverclick="Button1_ServerClick" />当点击按钮时 变量绑定的数据不能显示了,就是开始在页面加载时 我已经给变量绑定了数据。 我在执行按钮点击事件时,又重新绑定了数据,如:
protected void Button1_ServerClick(object sender, EventArgs e)
{
string email = txtGuestEmail.Value;
GuestRelation relation = new GuestRelation();
relation.GrEmail = email;
relation.GrState = "未回复";
int i = GuestRelationManage.InsertGuestRelation(relation);
if (email.Length == 0)
{
Page.RegisterStartupScript("1", "<script>alert('邮件不为空!');</script>");
DataBindCompany();
DataBindNotice();
ViewState["image"] = GetImage();
image = (string)ViewState["image"];
}
else if (email.Trim() == "请输入Email")
{
GetImage();
ScriptManager.RegisterStartupScript(Button1, this.GetType(), "warning",
"alert('未输入邮件地址!')", true);
ViewState["image"] = GetImage();
image = (string)ViewState["image"];
DataBindCompany();
DataBindNotice();
}
else
{
if (i > 0)
{
GetImage();
ScriptManager.RegisterStartupScript(Button1, this.GetType(), "warning",
"alert('信息发送成功!')", true);
DataBindCompany();
DataBindNotice();
ViewState["image"] = GetImage();
image = (string)ViewState["image"];
this.txtGuestEmail.Value = "请输入Email";
}
else
{
ScriptManager.RegisterStartupScript(Button1, this.GetType(), "warning",
"alert('信息发送失败!请与管理员联系!')", true);
DataBindCompany();
DataBindNotice();
ViewState["image"] = GetImage();
image = (string)ViewState["image"];
}
}
}
当执行点击事件弹出提示框时,页面滚动图片不滚动了, 查看源文件,又能看来用变量绑定的数据,
这是怎么回事啊? 急啊 谢谢各位高手了 谢谢 非常谢谢....
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货