Web Forms :: LoginView DropDownList?
Sep 6, 2010LoginView DropDownList4 = LoginView2.FindControl("DropDownList4") as LoginView;
DropDownList4.SelectedValue = "abc";
Why not find SelectedValue?
LoginView DropDownList4 = LoginView2.FindControl("DropDownList4") as LoginView;
DropDownList4.SelectedValue = "abc";
Why not find SelectedValue?
Trying to populating dropdownlist in LoginView from mysql db but am getting Object reference not set to an instance of an object error.
Protected Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender
i am getting this error "A control with ID 'NewAssignTL' could not be found for the trigger in UpdatePanel 'UpdatePanel'. " i have 2 problems i cannot access my dropdownList control from code behind and i triggers cannot access the control.
my.aspx page
<asp:LoginView
ID="LoginView1"
runat="server">
<RoleGroups>
<asp:RoleGroup
Roles="Administrator">
<ContentTemplate>
<asp:DropDownList
ID="NewAssignTL"
runat="server"
AutoPostBack="True"
ToolTip="Select
team leader name"
DataSourceID="SqlDataSource1"
DataTextField="Description"
DataValueField="GroupID"
/>
<asp:SqlDataSource
ID="SqlDataSource1"
runat="server"
ConnectionString="<%$
ConnectionStrings:ApplicationServices %>"
SelectCommand="SELECT
GroupID, Description FROM aspnet_Groups WHERE (Active = 'True')">
</asp:SqlDataSource>#
</ContentTemplate>
</asp:RoleGroup>
</RoleGroups>
</asp:LoginView>
<asp:UpdatePanel
ID="UpdatePanel"
runat="server"
UpdateMode="Conditional">
<ContentTemplate>
my gridview is here
<Triggers>
<asp:AsyncPostBackTrigger
ControlID="NewAssignTL"
EventName="SelectedIndexChanged"
/>
I have a Dropdownlist within a LoginView Control as follows:
[Code]....
And in my code behind I can successfully reference the dropdownlist as follows:
[Code]....
However as soon as I try to add an item to the dropdownlist it all falls apart: The (pseudo) code to add an item is:
[Code]....
The error I get is:
[Code]....
One of mine dropdownlist is inside a <AnonymousTemplate> and I unable to bind it.
View 1 RepliesI use master/content page and use this code (below) for validation, if I place the PasswordRecovery outside LoginView the validation is marked up correctly, but placed back inside the LoginView the PasswordRecovery compilation error is CS0103: The name 'PasswordRecovery1' does not exist in the current context.
[code]....
I've put a DropDownList control within a LoginView control. I've got 2 SqlDataSource controls outside of the LoginView control, with the intent of databinding the items that comprise the ListItems of the DropDownList control, and another one for the data is stored in another table which has what was previously saved for the selection. However, when I've assign the SqlDataSource control to the DropDownList control's DataSourceID for the lookup table, I'm used to seeing the fields from the SqlDataSource control appearing in the DataTextField and DataValueField properties. However, they're not appearing there at all. Moreover, even when I try to type them in, its as if VS 2010 refuses to allow them.
View 3 RepliesI am getting nullReferenceException - when i try to findcontrol from "loginView". it happend only when user role does not exist for Logged in users. its bit annoying, is there any way to handle this in codebehind.
View 2 RepliesI tried to add a loginview to this code:
[Code]....
I tried adding LoggedIn/AnonymousTemplates etc but it chucked up loads of errors, when I ran the application. The weird bit is, the errors didn't show up in the VB error section!Effectively what I'm trying to do is add <AnonymousTemplate> to the register bit and a <LoggedInTemplate> to a message saying "Your already Registered!"
I've got a loginview, with a panel inside it.
On the onload of the page i like to en/dis able the panel. But the Panel, i get with this code::
Panel
PanelAppointment = (Panel)LoginView1.FindControl("PanelAppointment"
);
if(PanelAppointment !=null
)
PanelAppointment.Visible = false;
is always null.
But the panel is available in the generated code... , its placed in a rolegroup of the loginview.
How can i access it?
can i use loginview and loginstatus without membership?
i mean only with formsauthentication? i mean when i press the loginstatus it deletes the auth cookie?
is it possible to have a cancel button on a LoginView control ? If so, how can this be done?
View 4 RepliesI have a loginview nested on a masterpage. Problem is that on local machine I see the loginviewy, but when I load it on server it does not show. Here is my masterpage html:
<body bgcolor="Black">
<form id="form1" runat="server">
<div align="center">
<asp:ScriptManager ID="ScriptManager1" runat="server">
[Code]....
I have a 2 textboxes in a Login View on my Content Page (login.aspx) and Login Button outside of Login View. I want to pass the values of those textboxes to the members of class when user hit Login button.
I have User.cs class which contains TxtLogin and StrLogin.
[Code]...
When I debug the program and enter correct username and password it should show me "Thank you" rather than it is showing me "Enter valid Username and Password".
I have a 2 textbox and a checkbox in a Login View on my Master Page, have trouble making a FindControl that works.
View 8 RepliesI'm currently developing a localized control which works as a wrapper for the default ASP.NET Login control.
This is my .ascx file:
[Code]....
Problem is, I have to set dynamically from CodeBehind the LogoutText attribute. I tried basically two things:
1. Declaring the Asp:LoginStatus normally in the .designers.ascx.cs file and setting the LogouText attribute's value runtime like this:
[Code]....
... but this does not seem to work since the LoginStatus control is declared into a LoginView control.
2. Setting the value using late bounds, but this fails since to retrieve the loginstatus i have to do such thing:
[Code]....
... but this fails too because late bound removes early references, so i cannot logout the user anymore since the runtime finds a duplicated LoginStatus control and cannot understand which is the right one, or at least i guess so.
I tried to check if someone had the same problem in the past and i found a couple of reports stating that i cannot do such thing like setting attributes runtime for nested controls.
Maybe i'm just missing something, but before throwing everything and setting that attribute statically in the .ascx i would like to make sure.
I tried to get the LoginName control inside LoginView LoggedIn template , despite several methods, the code still could not work.
I wished to change the default username to the customer name.
Here is the code:
<asp:LoginView ID="LoginView1" runat="server">
<LoggedInTemplate>
Hello, <asp:LoginName ID="LoginName1" runat="server"></asp:LoginName>
<br />
<div style="text-align: right; margin-right: 5px ">
<asp:LoginStatus ID="LoginStatus1" runat="server" LogoutPageUrl="~/Home.aspx" Font-Underline="True" />
</div></div>
</LoggedInTemplate>
</asp:LoginView>
At the code behind :
protected void Login1_LoggedIn(object sender, EventArgs e) {
LoginName loginName = LoginView1.FindControl("LoginName1") as LoginName;
Response.Write(loginName.ToString()); //for now I used Response.Write for testing purposes
}
In this code, I have a multi View below the Loginview. The page works fine when it loads, but when I click on a button that changies which view to display, The page looses the fact that it is logged in and renders the Anonymous Template. The system knows the person is still logged in so when I go to another page like Signin, it displays the loggedin Template.
[Code]....
I have a page that has a gridview which contains a loginview that contains hyperlinks with different navigateurls based on the role a user is in. When then page first loads everything displays correctly. However, if there is more that one page of data and the users clicks on a subsequent page, the column with the hyperlinks is blank (the anchor tag gets written out but no href and text) all of the other columns display correctly. If you click the back to page 1 the hyperlink is blank. The only way to get the data to redisplay is to reload the page.
Is this a proper use of the loginview control?
Within my ItemTemplate on a listview i have a link button carrying out a delete command. As it's a custom command i use the ItemCommand to do the deleting and have a stub itemdeleting.
It works fine set out like this however i only want the delete button to be available to logged in users. If i wrap the linkbutton in a loginview and then click on it the ItemCommand and ItemDeleting never get called the page just refreshes.
I have a gridview with columns 'Edit', 'Delete', 'View Results' and other details. The 'Edit' column opens a modal popup to edit the record. The 'View Result' column is in a login view and this column is only visible to users belonging to the group 'Manager' as below:
[Code]....
When the page is first loaded, the hyperlinks are displayed correctly. however, after editing a record and saving the changes, the 'View Results' column loses the hyperlink.
I tried creating a temp hyperlink column outside a loginview control and this seems to work correctly.
I've a datalist within the logged in template.On the page_load first I'm ensuring the visitor is logged in
[Code]...
[Code]...
However this doesn't work,I get the following error:Object reference not set to an instance of an object.
Highlighting:DataList1.DataSource = ds
If I take the loginview away then it works,but I thought the loginview1.findcontrol part would solve any problems.
This code works:
<div id="GridDiv" runat="server">
gridview would go in here....
</div>
GridDiv.Visible=false;
However, because I have a Div in LoginView2 I have to find with findcontrol.
This is not work:
LoginView Div = LoginView2.FindControl("GridDiv") as LoginView;
Div.Visible = false;
Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
[Code]....
Line 785:
Line 786:
Line 787: Div.Visible = false;
I have 2 dropdownlists, each one is in a seperate loginview. On the selectedindexchanged event of one dropdown, I want to repopulate the 2nd dropdown based on the selection.When the page loads it throws this error:"A control with ID 'DropDownList_Company' could not be found for the trigger in UpdatePanel 'UpdatePanel_Title'.Does anyone know how I can get around this?
<asp:LoginView ID="LoginView_Company" runat="server">
<RoleGroups>
<asp:RoleGroup Roles="Admin">
[code]...
I've come to a scenario where I need to databind something only if the user is logged in. To do this I am using the LoginView control to display a Login control when they are not logged in and a GridView control when they are logged in. However, when I databind to the GridView object in the LoginView, nothing ever gets displayed. I have been debugging it and I am databinding it to a DataTable that definitely has data in it, however nothing shows up.
Here is some of the code:
if (User.Identity.IsAuthenticated)
{
((GridView)LoginView1.FindControl("GridView1")).DataSource = dt;
((GridView)LoginView1.FindControl("GridView1")).DataBind();
}
Is there a particular reason that this should not work? Is it bad practice?