I have an asp.net label which is invisible.
When i insert something in DB i set it to visible=true
with a message "Record saved"
and it remains visible until another server side event is not fired. But the problem is that When i click on insert again wit empty fields required field validator invokes and gives message like
Please fill all the fields.
Record saved.
You can add this to the bottom of your page
<body>
<asp:Label runat="server" ID="Label1"></asp:Label>
<script>
//hide the label after 3 seconds
window.setTimeout(function(){
document.getElementById('<%= Label1.ClientID %>').style.display = 'none';
}, 3000);
</script>
</body>
And remember to set it visible from code-behind when needed again
Just hide the label on the client side when the user clicks the insert button
<asp:Label runat="server" ID="Label1" Visible="False"></asp:Label>
<asp:Button runat="server" ID="btnInsert" OnClientClick="hideLabel();" OnClick="btnInsert_OnClick" ValidationGroup="InsertValidation" CausesValidation="True" />
<script>
function hideLabel(){
document.getElementById('<%= Label1.ClientID %>').style.display = 'none';
}
</script>
Code behind:
protected void btnInsert_OnClick(object sender, EventArgs e)
{
Label1.Visible = true;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.