<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Script2.aspx.cs" Inherits="Javascript.Script2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script language="javascript" type="text/javascript">
function ClearValue(Text1, Text2) {
var txtClear1 = document.getElementById(Text1);
var txtClear2 = document.getElementById(Text2);
if (txtClear1 != null || txtClear2 != null)
{
txtClear1.outerText = "";
txtClear1.value = "";
txtClear1.innerText = "";
txtClear1.innerHTML = "";
txtClear1.outerHTML = ""
txtClear2.value = "";
txtClear2.innerText = "";
txtClear2.innerHTML = "";
txtClear2.outerHTML = ""
return false;
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="lblError1" runat="server" Text="Label1"></asp:Label>
<asp:Label ID="lblError2" runat="server" Text="Label2"></asp:Label>
<asp:Button ID="btnClose" runat="server" Text="Button"
onclick="btnClose_Click" />
</div>
</form>
</body>
</html>
namespace Javascript
{
public partial class Script2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
btnClose.Attributes.Add("onclick", "ClearValue('" + lblError1.ClientID + "','" + lblError2.ClientID + "')");
}
protected void btnClose_Click(object sender, EventArgs e)
{
}
}
}
here iam not able to clear the text value of Label .
once i clcik the button.here i am trigerring the function to clear the labels values.
but the text is not getting cleared.
any idea how to solve the issue.
thanks.