从Aspx文件重构Javascript代码

时间:2013-08-26 19:06:52

标签: javascript html asp.net css

我正在重构web项目,其中java脚本和css代码写在.aspx文件中。现在我从aspx文件中删除java脚本和css代码并维护相应的css和js文件中的代码aspx文件中的引用。

如果将java脚本代码写在一个地方并且在函数内部,那么对我来说很简单。在示例代码中,并非所有java脚本代码都在函数内部,而且一些脚本在div块内。我是无法将这些脚本放在单独的文件中。另外我是Java脚本和Web开发的新手,请帮助我。

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <script type="text/javascript">
       -------code-----------       
    </script>
    <% Html.EnableClientValidation(); %>
    <% using (Html.BeginForm())
       {%>
    <%: Html.ValidationSummary(true) %>
    <div class="formColWhole" style="width: 935px;">
          <script type="text/javascript">

              document.body.style.cursor = 'default';

              document.forms[0].action = '<% = ViewData["RegisterPageUrl"].ToString() %>';

              function IndicateProcessing() {
              if (typeof (Page_ClientValidate) == 'function') {
                  if (Page_ClientValidate() == false) { return false; }
              }


              var cancelButton = document.getElementById("<% = buttonCancel.ClientID %>");
              if (cancelButton != null) {
                  cancelButton.disabled = true;
              }

              document.body.style.cursor = 'wait';

              return true;
              }
              function submitForm() {
              IndicateProcessing();
              // _gaq.push(['_trackEvent', 'Register', 'Register submit Click', 'Register submit']);
              // avoid duplicate submission
              var button = $("#buttonSend");
              button.attr('disabled', true).html('');

              document.forms[0].submit();
                        }
          </script>
    </div>
    <div class="formColWhole" style="width: 100%;">
       --------code----

    </div>
    <script type="text/javascript">
        var selectCountryText = document.getElementById("<% = selectCountry.ClientID %>").value;
        var regions = document.getElementById("region");
        regions.firstChild.text = selectCountryText;
    </script>
</asp:Content>

0 个答案:

没有答案
相关问题