我有一个带有图像的DIV:
<div id='loadingmessage' style='display:none' runat="server">
<asp:Image ID="imgUpdateProgress" runat="server" ImageUrl="~/images/ajax-loader.gif" AlternateText="Loading ..." ToolTip="Loading ..." style="padding: 20px;position:fixed;top:35%;left:50%;" />
我可以像这样在jquery中显示和隐藏图像:
$('#loadingmessage').show();
$('#loadingmessage').hide();
我想在点击asp之后从代码中做同样的事情:RadioButton:
public void OnCheckedColumnMethodRequest(object sender, EventArgs e)
{
//hier I want to show the DIV and before the method is closed i want to hide it
我试过了:
loadingmessage.Visible = true;
loadingmessage.Style["display"] = "block";
但它不起作用。
答案 0 :(得分:0)
尝试使用CSS隐藏元素:
loadingmessage.Attributes.Add("style", "display:none");
或者,显示:
loadingmessage.Attributes.Add("style", "display:block");
答案 1 :(得分:0)
您还可以尝试使用css属性visibility(默认为可见,否则您可以说隐藏)
例如:loadingmessage.Attributes.Add("style", "visibility:visible");
答案 2 :(得分:0)
以上所有都很好,我建议直接从JavaScript更改它,而不是通过属性操纵它,但是对于他自己的属性。
然而,DOM操作的未来在于使用绑定框架(例如Knockout),以便您从ViewModel控制页面,使这种管理过时。
function toggelShowHide(elem) {
if (elem.style.display == 'none') {
elem.style.display = '';
}
else elem.style.display = 'none'
}
function toggelPicture()
{
var picture = document.getElementById('myPicture');
toggelShowHide(picture)
}