I'm working with the RadButton, encapsulated within an asp:Login container;
An application scenario includes the requirement of programmatically accessing textbox variables, and the RadButton;
All is OK, until the C# code attempts to process the button click event, programmatically;
Object reference not set to an instance of an object results on the line of: ((IPostBackEventHandler)submitButton).RaisePostBackEvent(null);
Any insight is appreciated; Best regards - Rob
An application scenario includes the requirement of programmatically accessing textbox variables, and the RadButton;
All is OK, until the C# code attempts to process the button click event, programmatically;
Object reference not set to an instance of an object results on the line of: ((IPostBackEventHandler)submitButton).RaisePostBackEvent(null);
Any insight is appreciated; Best regards - Rob
<asp:Login ID="LoginUser" runat="server" EnableViewState="false" RenderOuterTable="false"> <LayoutTemplate> <span class="failureNotification"> <asp:Literal ID="FailureText" runat="server"></asp:Literal> </span> <asp:ValidationSummary ID="LoginUserValidationSummary" runat="server" CssClass="failureNotification" ValidationGroup="LoginUserValidationGroup"/> <div class="accountInfo"> <fieldset class="login" style="border-style: none; border-color: Transparent"> <%-- <legend>Account Information</legend>--%> <p> <asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">Username:</asp:Label> <asp:TextBox ID="UserName" runat="server" CssClass="textEntry" Width="160px" AutoPostBack="true" ontextchanged="UserName_TextChanged"></asp:TextBox> <asp:RequiredFieldValidator ID="UserNameRequired" runat="server" ControlToValidate="UserName" CssClass="failureNotification" ErrorMessage="User Name is required." ToolTip="User Name is required." ValidationGroup="LoginUserValidationGroup">*</asp:RequiredFieldValidator> </p> <p> <asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password">Password:</asp:Label> <asp:TextBox ID="Password" runat="server" CssClass="passwordEntry" Width="160px"></asp:TextBox> <asp:RequiredFieldValidator ID="PasswordRequired" runat="server" ControlToValidate="Password" CssClass="failureNotification" ErrorMessage="Password is required." ToolTip="Password is required." ValidationGroup="LoginUserValidationGroup">*</asp:RequiredFieldValidator> </p> <p> </p> </fieldset> <p class="submitButton"> <telerik:RadButton ID="rbLogin" runat="server" CommandName="Login" Text="Log In" ValidationGroup="LoginUserValidationGroup" Font-Names="Microsoft Sans Serif" Skin="Black"> </telerik:RadButton> <telerik:RadButton ID="rbForgotPassword" runat="server" Text="Forgot Password" ValidationGroup="LoginUserValidationGroup" Font-Names="Microsoft Sans Serif" Skin="Black" onclick="rbForgotPassword_Click"> </telerik:RadButton> </p> </div> </LayoutTemplate> </asp:Login>
string
obtainUsername = Request.QueryString["Username"];
string obtainPassword = Request.QueryString["Password"];
var userNameTextBox = LoginUser.FindControl("UserName") as TextBox; var passwordTextBox = LoginUser.FindControl("Password") as TextBox;
userNameTextBox.Text = obtainUsername;
passwordTextBox.Text = obtainPassword;
var submitButton = LoginUser.FindControl("rbButton") as RadButton; ((IPostBackEventHandler)submitButton).RaisePostBackEvent(null);