0

我创建了一个用户控件:

<ajaxToolkit:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">  
</ajaxToolkit:ToolkitScriptManager>

   <table>
   <tr>
    <td>
      Start Date   
    </td>   
    <td>
      <asp:TextBox ID="StartDateTextBox" runat="server"></asp:TextBox>
      <ajaxToolkit:CalendarExtender ID="StartCal" OnClientDateSelectionChanged="dateSelectionChanged"
                runat="server" TargetControlID="StartDateTextBox">
      </ajaxToolkit:CalendarExtender>
      <asp:Button ID="PostBackButton" runat="server" Text="Button" Style="display: none"
                OnClick="PostBackButton_Click" />
    </td>
    <td>
       End Date
    </td>
    <td>
      <asp:TextBox ID="EndDateTextBox" runat="server"></asp:TextBox>

      <ajaxToolkit:CalendarExtender ID="EndCal" runat="server" OnClientDateSelectionChanged="dateSelectionChanged"
                TargetControlID="EndDateTextBox">
      </ajaxToolkit:CalendarExtender>
    </td>
    </tr>
    <tr>
    <td colspan="4">
      <asp:Chart ID="PlantRestarts" runat="server" Height="400px" Width="800px">
      <Series>
          <asp:Series Name="Series1" ChartType="Bar" Palette="BrightPastel" ChartArea="MainChartArea">
          </asp:Series>
      </Series>
      <ChartAreas>
          <asp:ChartArea Name="MainChartArea" Area3DStyle-Enable3D="true">
          </asp:ChartArea>
      </ChartAreas>
      </asp:Chart>
    </td>
    </tr>
    <tr>
    <td align="center" colspan="4">
      <asp:Button ID="PlantRestartsButton" runat="server" Text="Export To CSV" CommandName="Export"
                CommandArgument="PlantRestarts" OnClick="PlantRestartAttemptsButton_Click" />
    </td>
    </tr>
</table>

我有一个使用此控件的简单页面:

<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="CustomTestPage.aspx.cs" Inherits="TrendReporting.CustomTestPage" %>
<%@ Register TagPrefix="UserCtrl" TagName="CustomControl"  Src="Controls/TestUserControl.ascx" %>

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
<script type="text/javascript">

    function getSlide() {
        var i, x, y, ARRcookies = document.cookie.split(";");
        for (i = 0; i < ARRcookies.length; i++) {
            x = ARRcookies[i].substr(0, ARRcookies[i].indexOf("="));
            y = ARRcookies[i].substr(ARRcookies[i].indexOf("=") + 1);
            x = x.replace(/^\s+|\s+$/g, "");
            if (x == "slide") {
                return y;
            }
        }
    }

    var isPostBack = false;
    var current = getSlide();
    var slider2 = ['Books', 'Attempts', 'Attempt Book Comparison', 'Business Unit', 'Trend'];
    function formatText(index, panel) {
        return slider2[index - 1];
    }

    $(function () {

        if (!isPostBack) {
            slide = 1;
        }

        $('#slider2').anythingSlider({

            width: 800,       // if resizeContent is false, this is the default width  if panel size is not defined
            height: 400,       // if resizeContent is false, this is the default height if panel size is not defined
            buildArrows: true,
            startPanel: current,
            resizeContents: false,     // If true, solitary images/objects in the panel will expand to fit the viewport
            delay: 7000,    //7 seconds before transitioning to next slide
            autoPlay: true,     // This turns off the entire slideshow FUNCTIONALY, not just if it starts running or not
            navigationFormatter: formatText, // Format navigation labels with text
            forwardText: "&raquo;",
            backText: "&laquo;",
            onSlideComplete: function () {
                document.cookie = "slide=" +    $('#slider2').data('AnythingSlider').currentPage;
            }
        })
    });
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<ul id="slider2">
 <li class="panel1" style="width: 800px; height: 400px">
    <UserCtrl:CustomControl runat="server" />
</li>
</ul>

当我加载页面时,什么都没有显示,只是一个空白页面。问题是它从ajax toolscriptmanager 将一个脚本标签注入到<li> 标签中。源代码显示了这一点:

    <ul id="slider2">
 <li class="panel1" style="width: 800px; height: 400px">
    <script type="text/javascript">
 //<![CDATA[
   Sys.WebForms.PageRequestManager._initialize('ctl00$MainContent$ctl00$ToolkitScriptManager1', 'ctl01', [], [], [], 90, 'ctl00');
 //]]>
 </script>

<table>
   <tr>
        <td>
            Start Date
        </td>
        <td>
            <input name="ctl00$MainContent$ctl00$StartDateTextBox" type="text" id="MainContent_ctl00_StartDateTextBox" />

            <input type="submit" name="ctl00$MainContent$ctl00$PostBackButton" value="Button" id="MainContent_ctl00_PostBackButton" style="display: none" />
        </td>
        <td>
            End Date
        </td>
        <td>
            <input name="ctl00$MainContent$ctl00$EndDateTextBox" type="text" id="MainContent_ctl00_EndDateTextBox" />


        </td>
    </tr>
    <tr>
        <td colspan="4">
            <img id="MainContent_ctl00_PlantRestarts" src="/ChartImg.axd?i=chart_bbf484b6c44a4372abba2bb2591a3fb6_5.png&amp;g=dbfe90c2079e4257937543c8dc544c65" alt="" style="height:400px;width:800px;border-width:0px;" />
        </td>
    </tr>
    <tr>
        <td align="center" colspan="4">
            <input type="submit" name="ctl00$MainContent$ctl00$PlantRestartsButton" value="Export To CSV" id="MainContent_ctl00_PlantRestartsButton" />
        </td>
    </tr>
</table>





</li>
</ul>

有没有办法解决这个问题?

4

1 回答 1

1

我不使用ToolkitScriptManager,但我经常ScriptManager在我的网站上使用通用的 ajax 功能。使用ScriptManager,我通常将它放在 MasterPage 中,因为在任何特定页面上只能有一个实例,并且通过将它放在表单标记中它不会干扰任何 HTML 呈现。

于 2012-09-05T17:29:24.300 回答