后台数据传递到前台的问题,主要是写法的问题

lihome2002 2008-10-20 01:11:41
最近干的活很多需要javascript的东西,我这方面比较弱,知道要干什么,还是不会写。

请帮忙。

问题是这样的:

根据后台得到一个flag的值;
在前台进行判断,
string test ;
if(flag == true)
{
string test = BACKGROUND-IMAGE: .../images/redbomb01.gif;
}
else
{
test = string.empty;
}

因为是BACKGROUND-IMAGE。所以还要再写到下面的红色位置里去
<td style="WIDTH: 120px 这里" class="HeaderStyleL">
<asp:HyperLink ID="lnkInformation" runat="server">お知らせ</asp:HyperLink>
</td>

在前台怎么个写法,怎么调用后台这个flag?
...全文
122 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
lihome2002 2008-10-20
  • 打赏
  • 举报
回复
搞定了

style="WIDTH: 120px

分号忘记了

谢谢大家
xing020010 2008-10-20
  • 打赏
  • 举报
回复
前台
<td style="WIDTH: 120px background-image:url(<%=test%>)" class="HeaderStyleL">
用这个看看
lihome2002 2008-10-20
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 sy_binbin 的回复:]
.cs文件
protected void Page_Load(object sender, EventArgs e)
{
public string test ;
if(flag == true)
{
test = BACKGROUND-IMAGE: .../images/redbomb01.gif;
}
else
{
test = string.empty;
}
}
[/Quote]

安你的方法做了,只是
backimage = "BACKGROUND-IMAGE: url(/PCManagePRC/images/redbomb01.gif)"; 不加引号出错。

为啥结果没有显示出来啊?
sy_binbin 2008-10-20
  • 打赏
  • 举报
回复
.cs文件
protected void Page_Load(object sender, EventArgs e)
{
public string test ;
if(flag == true)
{
test = BACKGROUND-IMAGE: .../images/redbomb01.gif;
}
else
{
test = string.empty;
}
}

lihome2002 2008-10-20
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 sy_binbin 的回复:]
public string test ;
if(flag == true)
{
string test = BACKGROUND-IMAGE: .../images/redbomb01.gif;
}
else
{
test = string.empty;
}

<td style="WIDTH: 120px  <%=test%> " class="HeaderStyleL">
[/Quote]


请问这段写在前台还是后台?
if(flag == true)
{
string test = BACKGROUND-IMAGE: .../images/redbomb01.gif;
}
else
{
test = string.empty;
}

后台定义一个公用变量,前台就能直接引用了吗?
lihome2002 2008-10-20
  • 打赏
  • 举报
回复
大家果真很上手,我试一下去,回头给你们分哦。
菜谱 2008-10-20
  • 打赏
  • 举报
回复
用java嵌套就可以了,也不容易出错 如下:


<%

if(flag){ %>
<td style="WIDTH: 120px;BACKGROUND-IMAGE: .../images/redbomb01.gif" class="HeaderStyleL">
<%} else{ %>
<td style="WIDTH: 120px" class="HeaderStyleL">
<%
}
%>
我姓区不姓区 2008-10-20
  • 打赏
  • 举报
回复
<td style="WIDTH: 120px <%= test%>" class="HeaderStyleL">
sy_binbin 2008-10-20
  • 打赏
  • 举报
回复
public string test ;
if(flag == true)
{
string test = BACKGROUND-IMAGE: .../images/redbomb01.gif;
}
else
{
test = string.empty;
}

<td style="WIDTH: 120px <%=test%> " class="HeaderStyleL">

liuyilidan 2008-10-20
  • 打赏
  • 举报
回复
后台定义一个public变量
public string test;
.....
前台:
var test = "<%=test%>";
liuyilidan 2008-10-20
  • 打赏
  • 举报
回复
后台定义一个public变量
public string test;
.....
前台:
var test = "<%=test%>";

87,902

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧