2013-06-01 2 views
0

저는 asp.net 4.5 사용자 정의 양식을 가지고 있는데, 여기서는 처음 2 단계가 TemplatedWizardStep을 사용하여 배치됩니다.
2 단계에서 라디오 버튼 클릭 동작에 반응해야하는 javascript가 있습니다. 원래 1 단계에서 라디오 작업을했고 자바 스크립트가 예상대로 작동했습니다. 2 단계로 이동 했으므로 더 이상 작동하지 않습니다. 나는 방화 광으로 가서 스크립트를 보았지만 2 단계에서는 스크립트를 사용할 수 없었다. 2 단계의 컨트롤 중 페이지 소스보기에 아무 것도 포함되지 않았고 1 단계의 컨트롤 만 포함되었다. 체크 된 페이지 소스보기. 누구나 예상대로이 작업을 수행하는 방법을 알고 있습니까?사용자 만들기 마법사 2 단계 자바 스크립트가 응답하지 않습니다

감사

사용자 만들기 마법사

 <asp:CreateUserWizard runat="server" ID="RegisterUser" LoginCreatedUser="false" ViewStateMode="Disabled" 
      OnCreatedUser="RegisterUser_CreatedUser" ActiveStepIndex="0" 
      AnswerRequiredErrorMessage="Please answer selected question" 
      DuplicateUserNameErrorMessage="The user name is already in the system. Enter another user name."> 

      <LayoutTemplate> 
       <asp:PlaceHolder runat="server" ID="wizardStepPlaceholder" /> 
       <asp:PlaceHolder runat="server" ID="navigationPlaceholder" /> 
      </LayoutTemplate> 

      <WizardSteps> 
       <asp:TemplatedWizardStep ID="wzdStep1" runat="server" StepType="Start"> 
        <ContentTemplate> 
         <asp:UpdatePanel ID="UpdatePanelStep1" UpdateMode="Conditional" runat="server"> 
          <ContentTemplate> 

           <fieldset> 

            <ul> 
             <li> 
              <asp:Label ID="lblFullName" runat="server" AssociatedControlID="txtFullName">Full name</asp:Label> 
              <input runat="server" data-rule-minlength="2" data-rule-required="true" class="controltext" type="text" placeholder="Enter Full Name" id="txtFullName" /> 
             </li> 
             <li> 
              <asp:Label ID="lblCountry" runat="server" AssociatedControlID="ddCountry">Country</asp:Label> 
              <asp:DropDownList ID="ddCountry" AppendDataBoundItems="true" AutoPostBack="true" DataSourceID="lnqCountry" DataTextField="CntryName" DataValueField="CntryID" CssClass="controltext" runat="server"> 
               <asp:ListItem Value="-1">---Select Country---</asp:ListItem> 
              </asp:DropDownList> 

              <asp:LinqDataSource ID="lnqCountry" runat="server" 
               ContextTypeName="ClientStudio.SalonDataClassesDataContext" OrderBy="CntryName" 
               TableName="CntrysLUs"> 
              </asp:LinqDataSource> 
             </li> 
             <li> 
              <asp:Label ID="lblStates" runat="server" AssociatedControlID="ddStates">State</asp:Label> 
              <div class="input-append controltext" id="divStateSelect" style="display: inline-block"> 
               <asp:DropDownList ID="ddStates" data-rule-required="true" AutoPostBack="false" EnableViewState="true" AppendDataBoundItems="true" DataSourceID="lnqStates" DataTextField="StateName" DataValueField="StateID" CssClass="controltext" runat="server"> 
                <asp:ListItem Value="-1">---Select State---</asp:ListItem> 
               </asp:DropDownList> 
               <button class="button button-basic" id="btnAddState" onclick="addState();" type="button"> 
                Add 
               </button> 
              </div> 
              <div class="input-append input-prepend" id="divStateAdd" style="display: none"> 
               <span class="add-on"> 
                <i class="icon-edit"></i> 
               </span> 
               <input class="controltext" runat="server" id="txtStateName" type="text" placeholder="Enter State Name" /> 
               <button class="button button-basic" runat="server" id="btnSaveState" onclick="saveState"> 
                Save! 
               </button> 
               <button class="button button-basic" onclick="clearState();" id="btnClearState" type="button"> 
                Clear 
               </button> 
              </div> 
              <asp:LinqDataSource ID="lnqStates" runat="server" 
               ContextTypeName="ClientStudio.SalonDataClassesDataContext" OrderBy="StateName" 
               TableName="StatesLUs" Where="CntryID == @CntryID" 
               Select="new (StateID, StateName, CntryID)"> 
               <WhereParameters> 
                <asp:ControlParameter ControlID="ddCountry" Name="CntryID" 
                 PropertyName="SelectedValue" Type="Int32" /> 
               </WhereParameters> 
              </asp:LinqDataSource> 
             </li> 
             <li> 
              <asp:Label ID="lblCity" runat="server" AssociatedControlID="txtCity">City Name</asp:Label> 
              <input runat="server" data-rule-minlength="2" data-rule-required="true" class="controltext" type="text" placeholder="Enter City Name" id="txtCity" /> 
             </li> 
            </ul> 
           </fieldset> 
          </ContentTemplate> 
         </asp:UpdatePanel> 
        </ContentTemplate> 
        <CustomNavigationTemplate> 
         <div class="pull-right"> 
          <asp:Button ID="Button1" runat="server" CssClass="btn btn-success btn-large" CommandName="MoveNext" Text="Next" /> 
         </div> 
        </CustomNavigationTemplate> 
       </asp:TemplatedWizardStep> 
       <asp:TemplatedWizardStep ID="wzdStep2" StepType="Auto"> 
        <ContentTemplate> 
         <fieldset> 
          <ul> 
           <li> 
            <asp:Label ID="lblStylist" runat="server" AssociatedControlID="RadioButtonList1">Do you currently have a stylist or stylists?</asp:Label> 

            <asp:RadioButtonList ID="RadioButtonList1" AutoPostBack="false" onclick="javascript:radio(this);" CssClass="controltext" 
             RepeatLayout="Table" RepeatDirection="Vertical" RepeatColumns="1" 
             runat="server"> 
             <asp:ListItem Value="1" Selected="True"> <i> Yes, I have a stylist(s) I see on a regular basis</i></asp:ListItem> 
             <asp:ListItem Value="0"> <i> No, I am looking for a new stylist</i></asp:ListItem> 
            </asp:RadioButtonList> 
           </li> 
           <li id="liSearch" style="display: block"> 
            <asp:Label ID="Label1" runat="server">Find by Salon or Stylist Name</asp:Label> 
            <div class="clear"></div> 
            <br /> 
            <div class="input-append input-prepend"> 
             <span class="add-on"> 
              <i class="icon-search"></i> 
             </span> 
             <input class="controltext" type="text" id="FindBySalon" placeholder="Enter Salon Name..."></input> 
             <button class="button button-basic" onclick="findBySalon();" id="btnFindBySalon" type="button"> 
              Find by Salon! 
             </button> 
            </div> 
            <div class="clear"></div> 
            <div class="input-append input-prepend"> 
             <span class="add-on"> 
              <i class="icon-search"></i> 
             </span> 
             <input class="controltext" type="text" id="FindByStylist" placeholder="Enter Stylists Name..."></input> 
             <button class="button button-basic" onclick="findByStylist();" id="btnFindByStylist" type="button"> 
              Find by Stylists Name! 
             </button> 
            </div> 
           </li> 
           <li id="liResults" style="display: none"> 
            <asp:Label ID="lblResults" runat="server" AssociatedControlID="ddResults">Search Results</asp:Label> 
            <asp:DropDownList ID="ddResults" AutoPostBack="true" OnSelectedIndexChanged="ddResults_SelectedIndexChanged" CssClass="controltext" DataValueField="StylistID" DataTextField="Results" runat="server"></asp:DropDownList> 
           </li> 
           <li id="liSelf" style="display: none"> 
            <asp:Label ID="Label2" runat="server" AssociatedControlID="ddSelf">Is this you?</asp:Label> 
            <asp:DropDownList ID="ddSelf" CssClass="controltext" DataValueField="CustomerID" DataTextField="Results" runat="server"></asp:DropDownList> 
           </li> 
          </ul> 
         </fieldset> 

        </ContentTemplate> 
        <CustomNavigationTemplate> 
         <div class="pull-right"> 
          <asp:Button ID="Button2" runat="server" CssClass="btn btn-success btn-large" CommandName="MovePrevious" Text="Previous" /> 
          <asp:Button ID="Button3" runat="server" CssClass="btn btn-success btn-large" CommandName="MoveNext" Text="Next" /> 
         </div> 
        </CustomNavigationTemplate> 
       </asp:TemplatedWizardStep> 
       <asp:CreateUserWizardStep runat="server" ID="RegisterUserWizardStep"> 
        <ContentTemplate> 
         <p class="message-info"> 
          Passwords are required to be a minimum of <%: Membership.MinRequiredPasswordLength %> characters in length. 
         </p> 

         <p class="validation-summary-errors"> 
          <asp:Literal runat="server" ID="ErrorMessage" /> 
         </p> 

         <fieldset> 

          <ol> 
           <li> 
            <asp:Label runat="server" AssociatedControlID="UserName">User name</asp:Label> 
            <asp:TextBox runat="server" ID="UserName" /> 
            <asp:RequiredFieldValidator runat="server" ControlToValidate="UserName" 
             CssClass="field-validation-error" ErrorMessage="The user name field is required." /> 
           </li> 
           <li> 
            <asp:Label runat="server" AssociatedControlID="Email">Email address</asp:Label> 
            <asp:TextBox runat="server" ID="Email" TextMode="Email" /> 
            <asp:RequiredFieldValidator runat="server" ControlToValidate="Email" 
             CssClass="field-validation-error" ErrorMessage="The email address field is required." /> 
           </li> 
           <li> 
            <asp:Label runat="server" AssociatedControlID="Password">Password</asp:Label> 
            <asp:TextBox runat="server" ID="Password" TextMode="Password" /> 
            <asp:RequiredFieldValidator runat="server" ControlToValidate="Password" 
             CssClass="field-validation-error" ErrorMessage="The password field is required." /> 
           </li> 
           <li> 
            <asp:Label runat="server" AssociatedControlID="ConfirmPassword">Confirm password</asp:Label> 
            <asp:TextBox runat="server" ID="ConfirmPassword" TextMode="Password" /> 
            <asp:RequiredFieldValidator runat="server" ControlToValidate="ConfirmPassword" 
             CssClass="field-validation-error" Display="Dynamic" ErrorMessage="The confirm password field is required." /> 
            <asp:CompareValidator runat="server" ControlToCompare="Password" ControlToValidate="ConfirmPassword" 
             CssClass="field-validation-error" Display="Dynamic" ErrorMessage="The password and confirmation password do not match." /> 
           </li> 
           <li> 
            <asp:Label ID="lblSecurityQ" runat="server" AssociatedControlID="Question">Select Security Question</asp:Label> 
            <asp:DropDownList ID="Question" CssClass="controltext" runat="server"> 
             <asp:ListItem>What is your mother&#39;s maiden name?</asp:ListItem> 
             <asp:ListItem>What city were you born in?</asp:ListItem> 
             <asp:ListItem>What city was your mother born in?</asp:ListItem> 
             <asp:ListItem>What is your favorite sport?</asp:ListItem> 
             <asp:ListItem>What is your favorite pets name?</asp:ListItem> 
             <asp:ListItem>What grade school did you graduate from?</asp:ListItem> 
             <asp:ListItem>What is your favorite meal?</asp:ListItem> 
             <asp:ListItem>What is your favorite soap?</asp:ListItem> 
            </asp:DropDownList> 
           </li> 
           <li> 
            <asp:Label ID="lblSecurityAns" runat="server" AssociatedControlID="Answer">Security Answer</asp:Label> 
            <asp:TextBox ID="Answer" CssClass="controltext" runat="server"></asp:TextBox> 
            <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="Answer" 
             CssClass="field-validation-error" Display="Dynamic" ErrorMessage="Please enter the answer to selected question above." /> 
           </li> 
          </ol> 
         </fieldset> 
        </ContentTemplate> 
        <CustomNavigationTemplate> 
         <div class="pull-right"> 
          <asp:Button ID="Button4" runat="server" CssClass="btn btn-success btn-large" CommandName="MovePrevious" Text="Previous" /> 
          <asp:Button ID="Button5" runat="server" CssClass="btn btn-success btn-large" CommandName="MoveNext" Text="Next" /> 
         </div> 
        </CustomNavigationTemplate> 
       </asp:CreateUserWizardStep> 
       <asp:CompleteWizardStep ID="wzdComplete"> 
        <ContentTemplate> 
         <p> 
          Your account has been created, but before you can login you must first verify your email address. 
         </p> 
         <p> 
          A message has been sent to the email address you specified. Please check your email inbox and follow the instructions in that email to verify your account. 
         </p> 
         <br /> 
        </ContentTemplate> 
        <CustomNavigationTemplate> 
         <asp:Button ID="Button6" runat="server" CssClass="btn btn-success btn-large" CommandName="MovePrevious" Text="Previous" /> 
         <asp:Button ID="Button7" runat="server" CssClass="btn btn-danger btn-large" CommandName="Cancel" Text="Cancel" /> 
         <asp:Button ID="Button8" runat="server" CssClass="btn btn-primary btn-large" CommandName="MoveComplete" Text="Next" /> 
        </CustomNavigationTemplate> 
       </asp:CompleteWizardStep> 
      </WizardSteps> 
     </asp:CreateUserWizard> 

자바 스크립트

<script type="text/javascript"> 


    function radio(cnt) { 
     var radioButtons = document.getElementById("ContentPlaceHolder1_RegisterUser_ctl05_RadioButtonList1"); 
     var inputs = radioButtons.getElementsByTagName("input"); 
     var li = document.getElementById("liSearch"); 
     var liResults = document.getElementById("liResults"); 
     var liSelf = document.getElementById("liSelf"); 

     if (inputs[1].checked) { 

      li.style.display = "none"; 
      liResults.style.display = "none"; 
      liSelf.style.display = "none"; 

     } else { 

      li.style.display = "block"; 
      liResults.style.display = "block"; 
      liSelf.style.display = "block"; 
     } 

    } 
</script> 

답변

1

난 당신이 손 ID로 설정한다고 가정

ContentPlaceHolder1_RegisterUser_ctl05_RadioButtonList1

그리고 id를 step2로 옮길 때 id가 변경됩니다. 동적으로

변경은 같은 ID를 얻을 :

var radioButtons = document.getElementById("<%=RadioButtonList1.ClientID%>"); 

그것은 작동합니다.

+0

<% = RadioButtonList1.ClientID %>를 사용할 때 오류가 발생합니다. –

+1

감사합니다. 이름이 바뀌 었습니다. 클라이언트 ID를 설정하겠습니다. –

+0

@SheriTrager 마법사 내부 및 업데이트 패널 내에 있기 때문에 오류가 발생합니다. 따라서 RadioButton id는 찾기 컨트롤을 사용하는 경우 찾을 수 있습니다 - 어떻게 이것이 아이디어일까요? – Aristos