使用asp.net web表单+angularjs选项卡进行验证如何解决?

kyxcudwk  于 2021-09-29  发布在  Java
关注(0)|答案(0)|浏览(186)

我在使用asp.net web表单的一部分以及实现angularjs材质选项卡时遇到了这些问题。现在,当我写无效的数字时(我在这个输入上有验证器),我没有看到消息。但是,如果我删除了标签并保持原样,它会起作用。也许有人也面临同样的问题,并能建议在这种情况下该怎么办?

<asp:Content ID="Content3" ContentPlaceHolderID="_CPHFormBody" runat="server">
    <table width="100%">
        <tr>
            <td>
                <div ng-app="MyApp">
                    <div id="ctrl" ng-controller="AppCtrl">
                        <md-content class="md-padding">
                        <md-tabs md-selected="<%= ActiveTab %>" md-dynamic-height md-border-bottom>
                            <md-tab id="builder" label="General">
                                <md-tab-body>  
                                    <table style="width: 100%">
                                     <tr>
                                        <td>
                                            <asp:HiddenField runat="server" id="_HFErrorMessage" />
                                            <uc:DataProviderCommonFields ID="_UC1" runat="server" />
                                            <fc:TextBox ID="_UCWSUrl" runat="server" IsRequired="true" RemoveAutoComplete="true" RegExValidation="StringMaxLength8000" />
                                            <fc:DropDownList ID="_DDLAuthType" runat="server" IsRequired="false" AutoPostBack="true" OnTextChanged="_DDLAuthType_TextChanged" />
                                            <fc:TextBox ID="_UCUsername" runat="server" IsRequired="false" RemoveAutoComplete="true" RegExValidation="StringMaxLength255" />
                                            <fc:TextBox ID="_UCPassword" runat="server" IsRequired="false" RemoveAutoComplete="true" TextMode="Password" />
                                            <asp:Label AssociatedControlID="CertificateFile" ID="CertificateFileLabel" runat="server" />
                                            <span runat="server" id="CertificateStatus" />&nbsp;<asp:FileUpload ID="CertificateFile" runat="server" IsRequired="false" CssClass="CertificateFile" />
                                            <asp:CustomValidator ID="CertificateValidator" runat="server" ControlToValidate="CertificateFile" OnServerValidate="ValidateCertificate" CssClass="error" ValidateEmptyText="true" />
                                            <fc:TextBox ID="_UCContentType" runat="server" IsRequired="false" RemoveAutoComplete="true" RegExValidation="StringMaxLength100" />
                                            <fc:CheckBox ID="_UCCleanCharset" runat="server" Checked="false" />
                                            <fc:TextBox ID="_UCRequestHeaders" runat="server" IsRequired="false" RemoveAutoComplete="true" RegExValidation="StringMaxLength8000" />
                                            <fc:TextBox ID="_UCResponseHeaders" runat="server" IsRequired="false" RemoveAutoComplete="true" RegExValidation="StringMaxLength8000" />
                                            CustomerHeader1;CustomerHeader2; (You will be able to map values in the mapping screens).
                                            <fc:TextBox ID="_UCAllowedHttpStatusCodes" runat="server" IsRequired="false" RemoveAutoComplete="true" RegExValidation="StringMaxLength255" />
                                            Allowed http status codes seperated by commas, for example: 404,204
                                            <br />
                                            Http status codes above will be referred as "Success" 
                                            <fc:CheckBox ID="_CBIsBinaryResponse" runat="server" />
                                        </td>
                                    </tr>
                                </table>
                                </md-tab-body>
                            </md-tab>
                            <md-tab id="query" label="OAuth 2.0 settings">
                                <md-tab-body>
                                    <table style="width: 100%;">
                                        <tr>
                                            <td>
                                                <asp:Label ID="NoSettingsLbl" runat="server" Text="*No additional settings for X authentication type"></asp:Label>
                                                <asp:Label BackColor="Yellow" CssClass="warning" ID="_MultipleProfilesHint" Visible="false" runat="server" Text="*Please add 'ProfileID' parameter to interface when using multiple authentication profiles"></asp:Label>
                                                <asp:DataList
                                                    BorderColor="Black"
                                                    ID="Profiles" runat="server" ValidateRequestMode="Disabled">
                                                    <SeparatorTemplate>
                                                        <a>----------------------------------------------------------</a>
                                                    </SeparatorTemplate>
                                                    <ItemTemplate>
                                                        <div class="form-field">
                                                            <asp:Label runat="server" Text="ProfileID"></asp:Label>
                                                            <asp:TextBox ID="ID" Enabled="false" CssClass="textbox" Text='<%# Bind("ProfileID") %>' runat="server"></asp:TextBox>
                                                        </div>
                                                        <fc:DropDownList Label="Grant Type" ID="_DDLGrantType" runat="server" IsRequired="false" Text='<%#Eval("GrantType") %>' AutoPostBack="true">
                                                            <items>
                                                                <asp:ListItem Text="Authorization Code" />
                                                                <asp:ListItem Text="Implicit" />
                                                                <asp:ListItem Text="Password Credentials" />
                                                                <asp:ListItem Text="Client Credentials" />
                                                            </items>
                                                        </fc:DropDownList>
                                                        <fc:DropDownList 
                                                            Label="Add token to:" 
                                                            ID="_DDLHeaderOrURL" 
                                                            runat="server" 
                                                            Text='<%#Eval("AddTokenTo") %>' 
                                                            AutoPostBack="true">
                                                            <items>
                                                                <asp:ListItem Text="Header" />
                                                                <asp:ListItem Text="Url" />
                                                            </items>
                                                        </fc:DropDownList>
                                                        <div class="form-field">
                                                            <asp:Label runat="server" Text="Auth Url"></asp:Label>
                                                            <asp:TextBox ID="_AuthURL" CssClass="textbox" Text='<%# Bind("AuthUrl") %>' runat="server"></asp:TextBox>
                                                            <asp:RequiredFieldValidator runat="server" Text="Required" ControlToValidate="_AuthURL" Visible='<%# 
                                                                    (Eval("GrantType").ToString()=="Authorization Code" || Eval("GrantType").ToString()=="Implicit")
                                                                    && (Eval("AuthUrl") == null || string.IsNullOrEmpty(Eval("AuthUrl").ToString())) %>'
                                                                CssClass="srvvalidationtext">
                                                            </asp:RequiredFieldValidator>
                                                        </div>
                                                        <div class="form-field">
                                                            <asp:Label runat="server" Text="Access Token URL"></asp:Label>
                                                            <asp:TextBox ID="_AccessTokenURL" CssClass="textbox" Text='<%# Bind("AccessTokenUrl") %>' runat="server"></asp:TextBox>
                                                            <asp:RequiredFieldValidator runat="server" Text="Required" ControlToValidate="_AccessTokenURL" Visible='<%# 
                                                                    (Eval("GrantType").ToString()=="Authorization Code" || Eval("GrantType").ToString()=="Client Credentials" ||  Eval("GrantType").ToString()=="Password Credentials")
                                                                    && (Eval("AccessTokenUrl") == null || string.IsNullOrEmpty(Eval("AccessTokenUrl").ToString())) %>'
                                                                CssClass="srvvalidationtext">
                                                            </asp:RequiredFieldValidator>
                                                        </div>
                                                        <div class="form-field">
                                                            <asp:Label runat="server" Text="Username"></asp:Label>
                                                            <asp:TextBox ID="_Username" CssClass="textbox" Text='<%# Bind("Username") %>' runat="server"></asp:TextBox>
                                                            <asp:RequiredFieldValidator runat="server" Text="Required" ControlToValidate="_Username" Visible='<%# 
                                                                    (Eval("GrantType").ToString()=="Password Credentials")
                                                                    && (Eval("Username") == null || string.IsNullOrEmpty(Eval("Username").ToString())) %>'
                                                                CssClass="srvvalidationtext">
                                                            </asp:RequiredFieldValidator>
                                                        </div>
                                                        <div class="form-field">
                                                            <asp:Label runat="server" Text="Password"></asp:Label>
                                                            <fc:PasswordBox TextMode="Password" ID="_Password" Password='<%# Bind("Password") %>' runat="server"></fc:PasswordBox>
                                                            <asp:RequiredFieldValidator runat="server" Text="Required" ControlToValidate="_Password" Visible='<%# 
                                                                    (Eval("GrantType").ToString()=="Password Credentials")
                                                                    && (Eval("Password") == null || string.IsNullOrEmpty(Eval("Password").ToString())) %>'
                                                                CssClass="srvvalidationtext">
                                                            </asp:RequiredFieldValidator>
                                                        </div>
                                                        <div class="form-field">
                                                            <asp:Label runat="server" Text="Client ID"></asp:Label>
                                                            <asp:TextBox ID="_ClientID" CssClass="textbox" Text='<%# Bind("ClientId") %>' runat="server"></asp:TextBox>
                                                            <asp:RequiredFieldValidator runat="server" Text="Required" ControlToValidate="_ClientID" Visible='<%# 
                                                                    (Eval("ClientId") == null || string.IsNullOrEmpty(Eval("ClientId").ToString())) %>'
                                                                CssClass="srvvalidationtext">
                                                            </asp:RequiredFieldValidator>
                                                        </div>
                                                        <div class="form-field">
                                                            <asp:Label runat="server" Text="Client Secret"></asp:Label>
                                                            <fc:PasswordBox TextMode="Password" ID="_ClientSecret" Password='<%# Bind("ClientSecret") %>' runat="server"></fc:PasswordBox>
                                                            <asp:RequiredFieldValidator runat="server" Text="Required" ControlToValidate="_ClientSecret" Visible='<%# 
                                                                    (Eval("GrantType").ToString()=="Authorization Code" || Eval("GrantType").ToString()=="Client Credentials" || Eval("GrantType").ToString()=="Password Credentials")
                                                                    && (Eval("ClientSecret") == null || string.IsNullOrEmpty(Eval("ClientSecret").ToString())) %>'
                                                                CssClass="srvvalidationtext">
                                                            </asp:RequiredFieldValidator>
                                                        </div>
                                                        <div class="form-field">
                                                            <asp:Label runat="server" Text="Scope"></asp:Label>
                                                            <asp:TextBox ID="_Scope" CssClass="textbox" Text='<%# Bind("Scope") %>' runat="server"></asp:TextBox>
                                                        </div>
                                                        <div class="form-field">
                                                            <asp:Label runat="server" Text="Token"></asp:Label>
                                                            <asp:TextBox ID="_Token" CssClass="textbox" Enabled="false" Text='<%# Bind("AccessToken") %>' runat="server"></asp:TextBox>
                                                        </div>

                                                        <div class="form-field">
                                                            <asp:Label ID="ErrorLabel" runat="server" Visible="false" ForeColor="Red"></asp:Label>
                                                        </div>
                                                        <asp:Button OnClick="GetTokenClicked" CssClass="classname" runat="server" ID="_GetToken" Text="Get Token"></asp:Button>
                                                    </ItemTemplate>
                                                </asp:DataList>
                                                <br />
                                                <br />
                                                <br />
                                                <asp:Button runat="server" Text="Add Profile" CssClass="classname" OnClick="AddToken_Click" ID="_AddToken" />
                                            </td>
                                        </tr>
                                    </table>               
                                </md-tab-body>
                            </md-tab>      
                        </md-tabs>
                            </md-content>
                    </div>
                </div>
            </td>
        </tr>
    </table>
    <script src="../lib/angular/1.7.9/angular.min.js"></script>
    <script src="../lib/angular-animate/1.7.9/angular-animate.min.js"></script>
    <script src="../lib/angular-aria/1.7.9/angular-aria.min.js"></script>
    <script src="../lib/angular-resource/1.7.9/angular-resource.min.js"></script>
    <script src="../lib/angular-material/1.2.2/angular-material.min.js"></script>
    <script>
        angular.module('MyApp', ['ngMaterial']).controller('AppCtrl', function ($scope, $mdDialog) {
            var vm = $scope;

            var errorMessage = '<%=_HFErrorMessage.Value%>';
            angular.element(document).ready(function () {
                if (errorMessage.length > 0) {
                    showError(errorMessage);
                }
            });

            function showError(message) {
                $mdDialog.show(
                    $mdDialog.alert({
                        controller: function ($mdDialog) {
                            this.close = function () {
                                $mdDialog.hide();
                            },
                                this.cancel = function () {
                                    $mdDialog.cancel();
                                }
                        },
                        controllerAs: 'ctrl',
                        templateUrl: '../scripts/pages/views/error.tmp.html',
                        parent: angular.element(document.body),
                        clickOutsideToClose: true,
                        locals: {
                            message: message
                        }
                    }));
            };
        });
    </script>
</asp:Content>

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题