updatepanel在iframe中加载整个页面

时间:2010-08-02 15:44:07

标签: .net ajax updatepanel

我有一个显示在iframe内部的页面。 iframe使用UpdatePanel Ajax控件来更新其中的表单。然而,尽管Firefox很好,但整个页面都在IE中刷新。验证者也不要吵架。我的代码(使用Ajax)在iframe之外工作。发生了什么?谢谢你的帮助。我的代码是:

容器页面:

  <IFRAME id="frame1" width="600px" frameborder="0" height="390px" src="http://www.site.ac. uk/page.aspx" runat="server"></IFRAME>

page.aspx:

 <form id="form1" runat="server">
<div class="results"> 
  <asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>

<h3>Enter amount</h3>
   <span>$ <asp:TextBox CssClass="text" ID="TextBox1" runat="server"></asp:TextBox></span><br />


   <asp:Button ID="Button1" runat="server" CssClass="button" onClick="Button1_click" Text="Calculate" />
   <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1" Display="Dynamic"></asp:RequiredFieldValidator>
   <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="TextBox1" Display="Dynamic"
    ErrorMessage="" ValidationExpression="^\d+$"></asp:RegularExpressionValidator>


  <asp:UpdatePanel id="results" runat="server">
   <Triggers>
  <asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" />
  </Triggers>

  <ContentTemplate>
   <div class="amount"> 
   <h3>Amount</h3>
    <span>$ <asp:TextBox CssClass="text" ID="TextBox5" runat="server" ReadOnly="True"></asp:TextBox> </span><br />
 </div>


<h3>Total value:</h3>
 <span>$ <asp:TextBox ID="TextBox6" CssClass="text" runat="server" ReadOnly="True"></asp:TextBox> </span>

  </ContentTemplate>
  </asp:UpdatePanel>
   </div>

     </form>

page.aspx.vb

  Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

    TextBox5.Text = (TextBox1.Text * 0.333333).ToString("F2")
    TextBox6.Text = Val(TextBox1.Text) + Val(TextBox5.Text)
End Sub

1 个答案:

答案 0 :(得分:0)

Validator componant在更新面板内部不起作用,使用asp.net ajax-toolkit扩展并使用ValidatorCalloutExtender来控制和验证。它工作正常 Look at this video in Asp.net