在页面回发上存储和检索内容。

时间:2013-01-29 14:30:38

标签: asp.net

我希望以这样的格式存储内容,并能够在页面回发后检索。我可以使用隐藏字段吗?如果是这样的数据类型(不是字符串?)Stringbuilder?

    <b>Email Template:</b> UserAssignment
    <b>TO:</b> manojp.nayak@gmail.com<b>CC:</b> 
    <b>FROM:</b>admin@gmail.com <b>SUBJECT:</b>Task Assignment Project Activity  has been assigned to you.

    <b>BODY:</b> Deliverable Information :
    Test Deliverable 01 Test Issue 01   


    Project Activity  assigned by: Admin at: 2013-01-29 7:50 PM

    Automated Email Notification. Do not reply.

    Email Comments: 123test

    <b>FILES:</b> 

2 个答案:

答案 0 :(得分:1)

当然可以。 你可以使用类似的东西:

<asp:HiddenField ID="HiddenField_data" runat="server" />

从您的活动背后的代码中,您可以使用以下内容保存您想要的值:

HiddenField_data.Value = @"<b>Email Template:</b> UserAssignment
    <b>TO:</b> manojp.nayak@gmail.com<b>CC:</b> 
    <b>FROM:</b>admin@gmail.com <b>SUBJECT:</b>Task Assignment Project Activity  has been assigned to you.

    <b>BODY:</b> Deliverable Information :
    Test Deliverable 01 Test Issue 01   


    Project Activity  assigned by: Admin at: 2013-01-29 7:50 PM

    Automated Email Notification. Do not reply.

    Email Comments: 123test

    <b>FILES:</b> ";

答案 1 :(得分:1)

您可以使用用户控件来封装内容

可见性:您可以使用用户控件的Visible属性

持久性:您可以使用EnableViewState属性

链接:http://msdn.microsoft.com/fr-fr/library/system.web.ui.usercontrol(v=vs.80).aspx