隐藏标签和按钮在WPF
答
您可以添加属性d:IsHidden="true"
在这些元素上。
- 如果添加不存在的xmlns:d = “http://schemas.microsoft.com/expression/blend/2008”
- 放d:是否隐藏=”真正的”元素上要隐藏在设计时只
答
Aspx page:
___________
Enter Name:
<asp:TextBox ID="txtName" runat="server" />
<br />
<asp:Button Text="Submit" runat="server" OnClick="Submit" /><br />
<br />
<asp:Label ID="lblMessage" ForeColor="Green" Font-Bold="true" Text="Form has been submitted successfully." runat="server" Visible="false" />
Below is the code to make the Label visible on button click.
_________________________________________________________
protected void Submit(object sender, EventArgs e)
{
lblMessage.Visible = true;
ClientScript.RegisterStartupScript(this.GetType(), "alert", "HideLabel();", true);
}
Automatically Hiding Label control after 5 seconds using JavaScript
___________________________________________________________________
Below is the JavaScript function that will hide the Label after 5 seconds. This function gets called using ClientScript RegisterStartupScript method when the Button is clicked.
A variable seconds holds the value which determines after how many seconds the Label will hide. You can set whatever value you need in seconds as per your requirement.
Finally within JavaScript setTimeout function, the Label is hidden by setting its CSS display property to none and the timeout is specified by multiplying the ‘seconds’ variable to 1000 as setTimeout function accepts value in Milliseconds.
<script type="text/javascript">
function HideLabel() {
var seconds = 5;
setTimeout(function() {
document.getElementById("<%=lblMessage.ClientID %>").style.display = "none";
}, seconds * 1000);
};
</script>
你想隐藏在Visual Studio或在应用程序? –
在Visual Studio中,我可以在其下面放置另一个页面 –
在C#代码中? –