1

我正在尝试在我的 aspx 页面中显示在我的代码后面声明的公共字符串“TrialExtensionLengthDays”:

<asp:Button ID="ExtendTrialButton" runat="server" Text="Extend Trial" CssClass="actionButton extendTrialButton"  title="Extend Trial by <%=TrialExtensionLengthDays%> days" OnClientClick="confirm('Extend the Customer Demo by <%=TrialExtensionLengthDays%> days?')"/>

这是后面代码的相关部分:

Public Class EditTrialCustomer
    Inherits System.Web.UI.Page


    Public TrialExtensionLengthDays As String

Protected Sub Page_OnPreInit()
    TrialExtensionLengthDays = (System.Configuration.ConfigurationManager.AppSettings("TrialExtensionLengthDays"))
End Sub

为什么它不起作用?

4

2 回答 2

1

尝试使用Tooltip属性而不是标题。

使用页面加载中的代码来设置此属性:

protected void Page_Load(object sender, EventArgs e)
    {
        ExtendTrialButton.ToolTip = "Extend Trial by " + TrialExtensionLengthDays + " days";
        ExtendTrialButton.OnClientClick = "confirm('Extend the Customer Demo by" + TrialExtensionLengthDays + " days?')";
    }

而你的asp页面只是:

<asp:Button CssClass="actionButton extendTrialButton" ID="ExtendTrialButton"  runat="server" Text="Extend Trial"  />
于 2012-11-08T02:51:05.500 回答
0

尝试声明

TrialExtensionLengthDays StringBuilder 而不是 String

于 2012-11-08T04:50:38.620 回答