string strScript;
string strhtml = "<table>";
List<Main> listmain = new List<Main>();
listmain = mbll.getTop10Main();
for (int i = 0; i < listmain.Count;i++ )
{
strhtml += " <tr>";
strhtml += " <td>";
strhtml += " <a href='MainInfo.aspx?mid=" + listmain[i].Mid + "'>" + listmain[i].Workinfo.ToString() +" </a>";
strhtml += " </td>";
strhtml += " </tr>";
}
strhtml += " </table>"; strScript = " <script type='text/javascript'>";
strScript += "window.document.getElementById('sdiv').innerHTML = " + strhtml + ";";
strScript += " </script>";
Response.Write(strScript);
我在页面有这样一个层:
<div id="sdiv">
</div>
但是他始终抱 说window.document.getElementById('sdiv')对象为空,或不是对象。??????
请高手指点哈!!!
string strhtml = "<table>";
List<Main> listmain = new List<Main>();
listmain = mbll.getTop10Main();
for (int i = 0; i < listmain.Count;i++ )
{
strhtml += " <tr>";
strhtml += " <td>";
strhtml += " <a href='MainInfo.aspx?mid=" + listmain[i].Mid + "'>" + listmain[i].Workinfo.ToString() +" </a>";
strhtml += " </td>";
strhtml += " </tr>";
}
strhtml += " </table>"; strScript = " <script type='text/javascript'>";
strScript += "window.document.getElementById('sdiv').innerHTML = " + strhtml + ";";
strScript += " </script>";
Response.Write(strScript);
我在页面有这样一个层:
<div id="sdiv">
</div>
但是他始终抱 说window.document.getElementById('sdiv')对象为空,或不是对象。??????
请高手指点哈!!!
解决方案 »
- 关于C#的问题
- c# gdi+画图,如何统计图上的直线数目,即如何运用arraylist统计直线的数目?
- 有关 GridView 用字符串绑定数据 求助?
- 有没有可以在自已开发的系统中打开dwg格式文件的控件?
- 在B/S结构下,如何实现不同权限的用户 公文留转的实时控制
- select 和count 的问题。
- 在C#winform 中,如何遍历当前窗体中的全部textbox控件
- c#中的数据库问题。谢谢
- 请问一个关于从应用程序中请求一个http登陆连接资源的问题,请高手帮忙我在应用程序中:
- IIS——服务没有及时响应或控制请求,急!
- .net 调用 dll
- 小妹请教前辈DataGrideView里如何绑定ComboBox的问题。
</div>
window.document.getElementById('sdiv')对象为空,或不是对象。??????
window.document.getElementById('sdiv') 这句话,必须写在 <div id="sdiv"></div>
后面
<div id="sdiv">
<%= strhtml %>
</div>
public string SetDivHtml()
{
StringBulider html = new StringBulider();
html.Append("<table>");
...
return html.ToString();
}<div id="sdiv">
<%= SetDivHtml()%>
</div>
<%= strhtml %>
</div>