需求;点击linkbutton能控制table的显示与隐藏//内置按钮
function update()
{
alert("11");
document.getElementById("table_add").style.display="";//隐藏table
alert("22");
}
<asp:LinkButton ID="LinkButton1" runat="server" CommandName="update" CommandArgument='<%# Eval("id") %>'
OnClientClick="update()" >[修改]</asp:LinkButton>
protected void Repeater_address_ItemCommand(object source, RepeaterCommandEventArgs e)
{
if (e.CommandName == "update")
{
//int id = Convert.ToInt32(e.CommandArgument);
//ShouHuoAddress add = new ShouHuoAddress();
//add=UserBll.GetShouHuoAddressById(id);
//txt_address.Text = add.Address;
//txt_email.Text = add.Email;
//txt_mobile.Text = add.Mobile;
//txt_phone.Text = add.Phone;
//txt_ShouHuoName.Text = add.ShouHuoName;
//txt_zip.Text = add.Zip;
//Button1.Visible = false;
//btn_update.Visible = true;
//Response.Write("<script> document.getElementById('table_add').style.display='';</script>");
}
}我发现能输出11 跟22 那就说明执行了隐藏的JS,但是因为要执行ItemCommand里面的事件,直接刷新页面,table(默认隐藏)又被隐藏了。我把js输出在cs里面Response.Write(js脚本)。就会报错 说缺少对象。
请问如何解决
function update()
{
alert("11");
document.getElementById("table_add").style.display="";//隐藏table
alert("22");
}
<asp:LinkButton ID="LinkButton1" runat="server" CommandName="update" CommandArgument='<%# Eval("id") %>'
OnClientClick="update()" >[修改]</asp:LinkButton>
protected void Repeater_address_ItemCommand(object source, RepeaterCommandEventArgs e)
{
if (e.CommandName == "update")
{
//int id = Convert.ToInt32(e.CommandArgument);
//ShouHuoAddress add = new ShouHuoAddress();
//add=UserBll.GetShouHuoAddressById(id);
//txt_address.Text = add.Address;
//txt_email.Text = add.Email;
//txt_mobile.Text = add.Mobile;
//txt_phone.Text = add.Phone;
//txt_ShouHuoName.Text = add.ShouHuoName;
//txt_zip.Text = add.Zip;
//Button1.Visible = false;
//btn_update.Visible = true;
//Response.Write("<script> document.getElementById('table_add').style.display='';</script>");
}
}我发现能输出11 跟22 那就说明执行了隐藏的JS,但是因为要执行ItemCommand里面的事件,直接刷新页面,table(默认隐藏)又被隐藏了。我把js输出在cs里面Response.Write(js脚本)。就会报错 说缺少对象。
请问如何解决
解决方案 »
- asp.net 页面定时执行某个操作
- 哪位配置过 SQL缓存依赖 的仁兄 谈谈 它的性能怎样? 提升性能明显吗?
- 发布网站后,这个文件 PrecompiledApp.config 可以删除吗?
- 急用:Dll调用问题 急用急用急用
- 初学水晶报表,迷茫中,,急求各位指点,路过的进来帮下么
- 郁闷,做asp.net半年了,不知道下面该怎么走,请指教!
- 关于静态变量丢失的问题,再开一贴!!!请大家踊跃发言!!找出解决办法来!!!(2)
- 关于一个文件上传的问题!
- mvc路由怎么配置
- 程序能自动知道Cancel、Update、Delete吗?
- .net中在FTP中启动global的Application_Start的事件
- 动态table表 保存问题
findcontrol()
估计就成了吧.
else if (e.CommandName == "update")
{
foreach (RepeaterItem item in Repeater_address.Items)
{
Table t = new Table();
t=(Table)item.FindControl("table_add");
t.Visible = true;
}
}报未将对象引用到实例
这样不行啊 我不该这样写 我这写成内循环查找了
楼主 试试这个 如果还是不行的话 你就是刷新了页面了
Response.Write("<script> document.getElementById('table_add').style.display='';</script>");
这句改为调用页面的一个js方法。Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script type='text/javascript'>ShowTable();</script>");这个js方法就在你前台写好了