如何显示从code字符串中的页面背后 [英] How do I display string from code behind in page

查看:104
本文介绍了如何显示从code字符串中的页面背后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想显示一个公共字符串'TrialExtensionLengthDays那是在我的code声明的背后,我的aspx页面:

I'm trying to display a public string 'TrialExtensionLengthDays' that's declared in my code behind, in my aspx page:

<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?')"/>

这里的code的相关部分的后面:

Here's the relevant part of the code behind:

Public Class EditTrialCustomer
    Inherits System.Web.UI.Page


    Public TrialExtensionLengthDays As String

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

为什么不工作呢?

Why's it not working?

推荐答案

尝试使用的工具提示财产而不是头衔。

Try using Tooltip property instead of title.

使用$ C $在页面加载背后C到设置该属性:

Use code behind in Page Load to set this properties:

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页面只是:

and your asp page just:

<asp:Button CssClass="actionButton extendTrialButton" ID="ExtendTrialButton"  runat="server" Text="Extend Trial"  />

这篇关于如何显示从code字符串中的页面背后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆