1

I have Installed Ajax Extension and added reference to the application. I am facing very strange problem that my master page accept the Ajax Extension Tools where as my content page throw error like “Element ScriptManager/UpdatePanel is not a known Element."

My WebConfig:
<?xml version="1.0"?><configuration>

  <system.web>
  <customErrors mode="Off">

  </customErrors>
    <authentication mode="Windows"/>
  <pages>
    <controls>
      <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
    </controls>
  </pages>

  </system.web>
  </configuration>


My contentPage:
<%@ Page Language="C#"  MasterPageFile="~/yuva.master" AutoEventWireup="true"   CodeBehind="PicSave.aspx.cs" Inherits="YuvaRK12.PicSave" %>


 <asp:Content ID="MypicSave" runat="server"  ContentPlaceHolderID= "MainCPH" >
 <table id="Main" style="width:100%; height:350px; background-color:White;"><tr><td>

 <asp:Label ID="lbl1" runat="server"></asp:Label>
 <asp:Label ID="vis" runat="server" ></asp:Label>

   <table id="Photo" style=" margin-left:auto; margin-right:auto;">
   <tr><td>
         <asp:FileUpload ID="FileUpload1" runat="server"  />

   </td></tr>
   <tr><td>

       <input  id="ImageBT"  
               type="button" 
               value="Upload Image" 
               runat="server" 
               onserverclick="ImageBT_ServerClick" style=" float:left;" />

   </td></tr><tr><td style="border-style:ridge;  border-width:3px;">
   <center>

         <asp:Image id="MyImg" runat="server" 
                    style="width:150px; 
                    height:150px;"  
                    BorderStyle="solid" 
                    BorderWidth="1px"/>
   </center>
   </td></tr></table>  <!-- Photo End Here-->

    <center>
    <table><tr><td>
     <asp:Button ID="SBtn" runat="server" 
                 Text="Submit" BorderStyle="ridge"  
                 BorderWidth="4px" 
                 OnClick="SBtn_Click" />
   </td></tr></table>
   </center>

   </td></tr></table><!--Main End here-->
   </asp:Content>

What I am missing here?. Very strange Ajax Extension is working with master page but not with content page!. What is the solution of it?.

4

2 回答 2

2

是的。您可以在您的 Web 应用程序中使用 AJAX,而无需安装ajax 工具包

要在您的 Web 应用程序中使用 AJAX,您可以使用预定义的库。您可以在工具箱的“AJAX 扩展”下找到这些控件。使用脚本管理器更新面板将部分回发到服务器。

<form id="form1" runat="server">
<div>
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
        <asp:Button ID="Button1" runat="server" Text="Button" />
    </ContentTemplate>
    </asp:UpdatePanel>
    <asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
</div>
</form>

在上面的Button1代码 onclick 中,只有Label1会被传递给服务器,而不是Label2。更新面板之外的任何控件都不会转到服务器,因此它是部分回发。

您还可以探索有关触发器的更多信息,以使 AJAX 回调更有效。

注意: AJAX 工具包用于高级控件,如手风琴、动画等。对于简单的基于 AJAX 的 Web 应用程序,您不需要它们。

于 2013-08-26T10:33:48.447 回答
0

我利用黄金的两周来解决这个难题,终于成功了。我搜索了很多文章,大部分文章都建议如上所述,这对像我这样的新手造成了误解。

解决方案是:

<pages>
<controls>
  <add tagPrefix="ajax" namespace="System.Web.UI" assembly="System.Web.Extensions,   Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</controls>

在 web.config 配置的页面/控件部分中将“asp”更改为“ajax”将导致您完全控制现有 Asp.Net Web 应用程序中的 ajax 扩展。

于 2013-08-31T06:52:29.773 回答