我有ajax评级控制,我正试图在标签中捕获其额定值。
评级控制的代码是:
<asp:UpdatePanel runat="server" ID="upRating">
<ContentTemplate>
<act:Rating ID="rfixer" runat="server" CurrentRating="0" MaxRating="4" EmptyStarCssClass="emptypng" FilledStarCssClass="smileypng" StarCssClass="smileypng" WaitingStarCssClass="donesmileypng" OnChanged="Rating1_Changed">
</act:Rating>
<asp:Label ID="lblRating" runat="server" ForeColor="Red"></asp:Label>
</ContentTemplate>
</asp:UpdatePanel>
我在更改评级时更改标签文字:
protected void Rating1_Changed(object sender, AjaxControlToolkit.RatingEventArgs e)
{
System.Threading.Thread.Sleep(500);
int iRate = Convert.ToInt16(e.Value);
string strMessage = string.Empty;
switch (iRate)
{
case 1:
strMessage = "Not Useful";
break;
case 2:
strMessage = "Average";
break;
case 3:
strMessage = "Useful";
break;
case 4:
strMessage = "Informative";
break;
case 5:
strMessage = "Excellent";
break;
}
strMessage = "Thanks for Rating, You found this Question " + strMessage;
lblRating.Text = iRate.ToString();
// e.CallbackResult = strMessage;
}
但标签中的文字永远不会改变。
有什么问题?
答案 0 :(得分:1)
在评分控制中设置AutoPostBack="true"
<act:Rating ID="rfixer" runat="server" AutoPostBack="true" CurrentRating="0" MaxRating="4" EmptyStarCssClass="emptypng" FilledStarCssClass="smileypng" StarCssClass="smileypng" WaitingStarCssClass="donesmileypng" OnChanged="Rating1_Changed">
</act:Rating>