【问题标题】:Updating the master page when the control is within an update panel on the content page当控件位于内容页面上的更新面板中时更新母版页
【发布时间】:2011-11-17 20:51:29
【问题描述】:

我有一个应用程序,它在更新面板中有一个控件,但需要更新母版页的一部分 - 我不确定这是否可以完成?

 <asp:ScriptManager ID="ScriptManager" runat="server" />

在母版页内 我要更新的母版页部分如下:

<div id="divPanelMyCover" class="divPanelMyCover" runat="server">
                                <div class="sectionYourProtection">
                                    <div class="sectionPadding">
                                        <h4>Title</h4>
                                    </div>
                                    <div class="innerPanelMyCover">
                                        <br/>
                                        <ul class="bulletList" type="square">
                                            <li><span class="spBold">Monthly Payment: </span><asp:Label ID="lblMonthlyPayment" runat="server" Text=""></asp:Label                                                                                        </div>
   </div>
 </div> 

后面的代码:

 lblMonthlyPayment.Text = Convert.ToString(application.Premium);

lblMonthlyPayment 需要根据用户在内容页面上的选择进行更改,但由于控件位于更新面板中,因此无法正常工作。

内容页面:

 <asp:UpdatePanel ID="upUpSell" runat="server">
             <ContentTemplate>  
<div id ="divSlider" runat="server" visible="false">
                        <br />
                        <h3>If you want, you can change the amount ... </h3>
                                                    <hr />
                        <div class="sliderContainer"> 
                           <telerik:RadSlider id ="rdSlider" AutoPostBack="true" runat="server" Orientation="Horizontal" Width="450"
                                        Height="70" MinimumValue="0" MaximumValue="50" LargeChange="10" TrackPosition="BottomRight"
                                        ItemType="Tick" IsSelectionRangeEnabled="false" SelectionStart="10" SelectionEnd="30" Skin="Default" DragText="Select Premium" >

                            </telerik:RadSlider>
                        </div>
                        <asp:Label ID="lblValue" runat="server" Text="" Visible="false"></asp:Label>
                    </div>                   

c#

protected void Page_Load(object sender, EventArgs e)
    {
        //if (!Page.IsPostBack)

         //Pre-populate the screen with data from ApplicationBO
        ApplicationBO application = (ApplicationBO)Session["Application"];

        if (!Page.IsPostBack)
        {
            if (Session["Application"] == null)
                application = new ApplicationBO();
            else
                application = (ApplicationBO)Session["Application"];
            lblclientName.Text = application.FirstName;
            rdSlider.Value = Convert.ToDecimal(application.Premium);
            lblMonthlyPayment.Text = Convert.ToString(application.Premium);
        }

        divSlider.Visible = true;

        string upsellValue = Convert.ToString(application.Premium);

        if (divSlider.Visible == true)
        {
            upsellValue = Convert.ToString(rdSlider.Value);

            // Save the current page information
            application.Premium = Convert.ToDecimal(upsellValue);

        }

提前谢谢...

【问题讨论】:

    标签: c# asp.net updatepanel master-pages


    【解决方案1】:

    用 UpdateMode="Always" 的 UpdatePanel 包装标签

    【讨论】:

    • 是母版页上的 lblMonthlyPayment 是什么样子的?
    • 我尝试了几种不同的方法,但似乎没有成功 - 母版页面板仍然没有更新。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多