我有一个asp标签,其文本在网页中动态更改。我有一个按钮。当我单击按钮时,我必须保留标签的文本,而是由于回发而将值设置为初始值。任何人都可以帮我弄清楚如何保留标签的文字。提前致谢。
这是代码
<asp:Label ID="lblRate" runat="server" Text="" ></asp:Label>
这是我要更改标签的地方
<script type="text/javascript">
function Decide(option) {
var temp = "";
document.getElementById('<%=lblRate.ClientID%>').innerText = "";
if (option == 1) {
document.getElementById('<%=Rating1.ClientID%>').className = "Filled";
document.getElementById('<%=Rating2.ClientID%>').className = "Empty";
document.getElementById('<%=Rating3.ClientID%>').className = "Empty";
document.getElementById('<%=Rating4.ClientID%>').className = "Empty";
document.getElementById('<%=Rating5.ClientID%>').className = "Empty";
temp = "1";
}
if (option == 2) {
document.getElementById('<%=Rating1.ClientID%>').className = "Filled";
document.getElementById('<%=Rating2.ClientID%>').className = "Filled";
document.getElementById('<%=Rating3.ClientID%>').className = "Empty";
document.getElementById('<%=Rating4.ClientID%>').className = "Empty";
document.getElementById('<%=Rating5.ClientID%>').className = "Empty";
temp = "2";
}
if (option == 3) {
document.getElementById('<%=Rating1.ClientID%>').className = "Filled";
document.getElementById('<%=Rating2.ClientID%>').className = "Filled";
document.getElementById('<%=Rating3.ClientID%>').className = "Filled";
document.getElementById('<%=Rating4.ClientID%>').className = "Empty";
document.getElementById('<%=Rating5.ClientID%>').className = "Empty";
temp = "3";
}
if (option == 4) {
document.getElementById('<%=Rating1.ClientID%>').className = "Filled";
document.getElementById('<%=Rating2.ClientID%>').className = "Filled";
document.getElementById('<%=Rating3.ClientID%>').className = "Filled";
document.getElementById('<%=Rating4.ClientID%>').className = "Filled";
document.getElementById('<%=Rating5.ClientID%>').className = "Empty";
temp = "4";
}
if (option == 5) {
document.getElementById('<%=Rating1.ClientID%>').className = "Filled";
document.getElementById('<%=Rating2.ClientID%>').className = "Filled";
document.getElementById('<%=Rating3.ClientID%>').className = "Filled";
document.getElementById('<%=Rating4.ClientID%>').className = "Filled";
document.getElementById('<%=Rating5.ClientID%>').className = "Filled";
temp = "5";
}
document.getElementById('<%=lblRate.ClientID%>').innerText = temp;
return false;
}
</script>
这是按钮
<asp:Button ID="btnRatingSubmit" runat="server" Text="Button" OnClientClick="btnRatingSubmit"/>
有人可以帮我吗?