清风的细雨 2021-10-25 10:00 采纳率: 77.8%
浏览 90
已结题

ASP从后台改变前端div部分代码

如题,我想实现就是点击按钮,从后台调用click函数中的代码 改变前端某一div部分的代码,从而实现网页数据更改的效果。但是现在从后台该如何获取前台的这个div的id呢?求老哥们指教

前台div部分↓

<div style="width:90%; height: auto; margin:0 auto 0 100px;" id="s1">

</div>

-

    protected void Button1_Click(object sender, EventArgs e)
    {
        //规定了关键词查找的参数为“爱情”
        string value2 = "爱情";
        //以下是表的创建实例
        Website.Model.Flower[] flower = Website.DAL.FlowerDAL.FindSpecific1(value2);
        Website.Model.CombinationFlowers[] cflower = Website.DAL.CombinationFlowersDAL.FindSpecific1(value2);
        //以下是通过创建表格来显示数据库数据的前台代码
        Response.Write("<table style='border:1px solid black;width:1000px; height: 51px; margin:0 auto 0 140px;'align='center' ><tr style='border:1px solid black;' align='right'><td style='border:1px solid black;width:45px'><input type=button name='clickmeToSubmit' value='按花材搜索' onclick='callvalue2()' BackColor='#F6CAD2' BorderColor='White' style='border-style: none; font-family: 黑体; font-size: medium; margin-top: 0px; margin-left: 0px; height: 37px; width: 89px; background-color: #FEDFF4;' />   <input type=button name='clickmeToSubmit' value='按花束搜索' onclick='callvalue3()' BackColor='#F6CAD2' BorderColor='White' style='border-style: none; font-family: 黑体; font-size: medium; margin-top: 0px; margin-left: 0px; height: 37px; width: 89px; background-color: #FEDFF4;' /></td></tr></table>");
        Response.Write("<table style='border:1px solid black;width:1000px; height: 51px; margin:0 auto 0 140px;'align='center' ><tr style='border:1px solid black;' align='center'>");
        Response.Write("<td style='border:1px solid black;width:45px'>鲜花编号</td>");
        Response.Write("<td style='border:1px solid black;width:100px'>名称</td>");
        Response.Write("<td style='border:1px solid black;width:150px'>封面</td>");
        Response.Write("<td style='border:1px solid black;width:50px'>鲜花售价</td>");
        Response.Write("<td style='border:1px solid black;width:200px'>花语</td>");
        Response.Write("<td style='border:1px solid black;width:35px'>颜色</td>");
        for (int i = 0; i < cflower.Length; i++)
        {
            Response.Write("<table style='border:1px solid black;width:1000px; height: 51px; margin:0 auto 0 140px;' align='center'><tr style='border:1px solid black;'>");
            Response.Write(" <tr style='border:1px solid black;' align='center'>");
            Response.Write("  <td style='border:1px solid black;width:45px'>" + cflower[i].cf_id + "</td>");
            Response.Write("  <td style='border:1px solid black;width:100px'><a href='SingleCFlowerCheck.aspx?CFid=" + cflower[i].cf_id + "' target='_blank'>" + cflower[i].cf_name + "</a></td>");
            Response.Write("  <td style='border:1px solid black;width:150px'><img src='../Image/FlowerImage/" + cflower[i].cf_img + "'width='100px' height='100px'/></td>");
            Response.Write("  <td style='border:1px solid black;width:50px'>" + cflower[i].cf_price + "</td>");
            Response.Write("  <td style='border:1px solid black;width:200px'>" + cflower[i].cf_desc + "</td>");
            Response.Write("  <td style='border:1px solid black;width:35px'>" + cflower[i].cf_color + "</td>");
            Response.Write("</tr></table>");
        }
        for (int i = 0; i < flower.Length; i++)
        {
            Response.Write("<table style='border:1px solid black;width:1000px; height: 51px; margin:0 auto 0 140px;' align='center'><tr style='border:1px solid black;'>");
            Response.Write(" <tr style='border:1px solid black;' align='center'>");
            Response.Write("  <td style='border:1px solid black;width:45px'>" + flower[i].f_id + "</td>");
            Response.Write("  <td style='border:1px solid black;width:100px'><a href='SingleFlowerCheck.aspx?Fid=" + flower[i].f_id + "' target='_blank'>" + flower[i].f_name + "</a></td>");
            Response.Write("  <td style='border:1px solid black;width:150px'><img src='../Image/FlowerImage/" + flower[i].f_img + "'width='100px' height='100px'/></td>");
            Response.Write("  <td style='border:1px solid black;width:50px'>" + flower[i].sales_price + "</td>");
            Response.Write("  <td style='border:1px solid black;width:200px'>" + flower[i].f_desc + "</td>");
            Response.Write("  <td style='border:1px solid black;width:35px'>" + flower[i].f_color + "</td>");
            Response.Write("</tr></table>");
        }
        Response.Write("</tr></table>");
        Response.End();/////////////结束输出
    }
}

img

我现在的后台代码虽然实现了更改数据显示但是它是更改的整个界面的数据显示,我想让他只更改div部分的代码,请问各位老哥指教该如何修改。

  • 写回答

2条回答 默认 最新

  • Yijing Sun 2021-10-25 11:03
    关注

    你好,
    如果你想要得到div 的id, 你可以给div 加上 "runat="server".

    <div id="div1" runat="server">
    </div>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 11月4日
  • 已采纳回答 10月27日
  • 创建了问题 10月25日

悬赏问题

  • ¥15 这种微信登录授权 谁可以做啊
  • ¥15 请问我该如何添加自己的数据去运行蚁群算法代码
  • ¥20 用HslCommunication 连接欧姆龙 plc有时会连接失败。报异常为“未知错误”
  • ¥15 网络设备配置与管理这个该怎么弄
  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来