Password Recovery tool in C# not working - c#

Hi (I'm pretty new to this),
I have created a portal where the user logs in and within that, they can view other programs I've made. The problem is the password recovery does not seem to be working - I get no error messages, I just get the message "We were unable to access your information. Please try again."
I have the ASP.NET configuration setup correctly and have tested this with different users and permissions but I was just wondering if there is something I need to do in the configuartion manager or the web.config so that this can work.
Below is the code for the password recovery tool:
<form id="form1" runat="server">
<div align="center">
<asp:PasswordRecovery ID="PasswordRecovery1" runat="server" Height="147px" Width="442px" BackColor="#F7F6F3" BorderColor="#E6E2D8" BorderPadding="4" BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana" Font-Size="0.8em">
<UserNameTemplate>
<table border="0" cellpadding="1" cellspacing="0" style="border-collapse: collapse">
<tr>
<td style="width: 445px">
<table border="0" cellpadding="0" style="width: 442px; height: 147px">
<tr>
<td align="center" colspan="2">
<strong><span style="font-size: 0.9em">Password Recovery</span></strong></td>
</tr>
<tr>
<td align="center" colspan="2">
</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">Username:</asp:Label></td>
<td style="width: 291px">
<asp:TextBox ID="UserName" runat="server" Width="187px"></asp:TextBox>
<asp:RequiredFieldValidator ID="UserNameRequired" runat="server" ControlToValidate="UserName"
ErrorMessage="User Name is required." ToolTip="User Name is required." ValidationGroup="PasswordRecovery1">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="center" colspan="2" style="color: red">
<asp:Literal ID="FailureText" runat="server" EnableViewState="False"></asp:Literal>
</td>
</tr>
<tr>
<td align="right" colspan="2" style="text-align: right">
<asp:Button ID="SubmitButton" runat="server" CommandName="Submit" Text="Submit" ValidationGroup="PasswordRecovery1"
Width="103px" />
</td>
</tr>
</table>
</td>
</tr>
</table>
</UserNameTemplate>
<InstructionTextStyle Font-Italic="True" ForeColor="Black" />
<SuccessTextStyle Font-Bold="True" ForeColor="#5D7B9D" />
<TextBoxStyle Font-Size="0.8em" />
<TitleTextStyle BackColor="#5D7B9D" Font-Bold="True" Font-Size="0.9em" ForeColor="White" />
<SubmitButtonStyle BackColor="#FFFBFF" BorderColor="#CCCCCC" BorderStyle="Solid"
BorderWidth="1px" Font-Names="Verdana" Font-Size="0.8em" ForeColor="#284775" />
</asp:PasswordRecovery>
</div>
</form>
Thank you.

If you get this error ("We were unable to access your information. Please try again") for one user (but other users work fine), most likely it's just the account is locked.
To unlock the account run the stored procedure: [aspnetdb].[dbo].[aspnet_Membership_UnlockUser]
You need to pass in your application name, and the username to unlock.
If you don't know your application name, you can check from the [aspnetdb].[dbo].[aspnet_Applications] table.

Looks right to me.
Check your webconfig to make sure your membership provider has
enablePasswordRetrieval="false"
enablePasswordReset="true"
requiresQuestionAndAnswer="false"
Also you need to set up a mail definition in your web.config for the control to be able to mail the new password.
<mailSettings>
<smtp from="from#from.com">
<network host="your.smtp.server" port="25"/>
</smtp>
</mailSettings>

Related

Not able to hide Table row/message in code behind using c#

On Combo box selection change event i set the visible property of table and row to hide the message. But its not working.
Here is my code :
<telerik:RadMultiPage ID="RadMultiPage1" runat="server" SelectedIndex="0">
<telerik:RadPageView ID="RadPageViewCaregiver" runat="server">
<div class="container">
<telerik:RadToolTipManager ID="RadToolTipManager1" OffsetY="-1" HideEvent="ManualClose"
Width="200px" Height="250px" runat="server" OnAjaxUpdate="OnAjaxUpdate" RelativeTo="Element"
Position="MiddleLeft" ManualClose="True" ShowEvent="OnClick">
</telerik:RadToolTipManager>
<table border="0" cellpadding="0" cellspacing="0" style="width: 100%; height: 100%">
<tr>
<td align="center" valign="top" style="width: 100%">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr height="30px" valign="top" id="trmessage" runat="server" visible="false">
<td valign="middle" align="center">
<table border="0" cellpadding="0" cellspacing="0" width="98%" id="tbluser" runat="server"
visible="False">
<tr id="Tr1" runat="server">
<td id="Td1" align="left" runat="server">
<asp:Label ID="lblmessage" runat="server"></asp:Label>
</td>
</tr>
</table>
</td>
</tr>
I also tried to set the style for display to 'none' instead of visible to 'false' but it doesn't work either.
Can you give Any solution??
try display property to hide table. try this set of code.
tblAssignPatientMessage.Style.Add("display","none");
if the table style is set to be none then the tr style will also set to be hidden. if that doesn't work try this
trAssignPatientParentRow.Style.Add("display","none");
use this set of code to make the table visible.
tblAssignPatientMessage.Style.Add("display","block");
and for tr add this.
trAssignPatientParentRow.Style.Add("display","block");
and make sure that your table is not using any cssclass.

Website starts working after a few seconds

I am quite new in websites and web applications. I have created a website which works correctly on localhost IIS but when I put it on server it is not working properly. I have to wait for a while until it starts working. I also get the following error when I select items in dropdown: (it's on the bottom-left corner of the window)
Webpage error details
User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET4.0C; .NET4.0E; InfoPath.3; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 1.1.4322; MS-RTC LM 8)
Timestamp: Tue, 26 Mar 2013 13:07:37 UTC
Message: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed.
Line: 869
Char: 13
Code: 0
I set the trace to true and it works now. But it doesn't seem to be a good solution as I still see that error when I select items in dropbox. Do you have any good suggestion for this? should I add or remove something from configuration file or somewhere else? Following is my web.cinfig
<?xml version="1.0"?>
<configuration>
<system.web>
<customErrors mode="Off"/>
<compilation targetFramework="4.0" debug="true"/>
<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"
viewStateEncryptionMode="Always"/>
<trace
enabled="true"/>
</system.web>
</configuration>
Sys.WebForms.PageRequestManagerParserErrorException - what it is and how to avoid it,
If you've used the Microsoft ASP.NET AJAX UpdatePanel control, there's a good chance you've hit the "Sys.WebForms.PageRequestManagerParserErrorException" error.
I actually no sure what is throwing this error. in my webform im using updatepanel. rhis is part of my web form.
<%# Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>DTC</title>
</head>
<body bgcolor="#333333">
<h1 align="center" style="font-family: Arial; color: #FFFF99; height: 40px; font-
weight: bold;
font-size: 50px; min-width: 900px;" title="Header">
DTC Viewer</h1>
<form id="form1" runat="server" style="margin: 50px 100px 50px 100px; min-width: 700px;
background-color: #C0C0C0; font-family: Arial, Helvetica, sans-serif;">
<div align="center" style="width: 100%">
<asp:UpdatePanel ID="CheckboxUpdatePanel" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<table id="MainTable" runat="server" style="margin-left: 100px;">
<tr>
<td>
<asp:UpdatePanel ID="BrandUpdatePanel" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<table>
<tr>
<td style="padding-bottom: 5px;">
<asp:Label ID="BrandLabel" runat="server" Text="Brand :" Font-Names="Arial" Font-Size="Medium"
ForeColor="#333333" CssClass="MyLabel" Width="8em"
style="margin-right: 1em;text-align: right;"></asp:Label>
</td>
<td style="padding-bottom: 5px;">
<asp:TextBox ID="Brand" runat="server" Height="15px" Width="176px" Text="VTC" BackColor="#FFFFCC"
CssClass="MyDropBox" AutoPostBack="True" ForeColor="#666666" ReadOnly="True"></asp:TextBox>
<asp:Label ID="StarLabel1" runat="server" Font-Names="Arial" Font-Size="Medium"
ForeColor="#333333" Width="1em"
style="text-align: left;" Text="*"></asp:Label>
</td>
<td style="padding-bottom: 5px;">
<asp:RequiredFieldValidator ID="BrandValidator" runat="server" ErrorMessage="Basic Search: Brand is required"
ControlToValidate="Brand" InitialValue="" ForeColor="Red" Width="15em" CssClass="ErrorMessage"
Font-Size="Small"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="ModelLabel" runat="server" Text="Model :" Font-Names="Arial" Font-Size="Medium"
ForeColor="#333333" CssClass="MyLabel" Width="8em"
style="margin-right: 1em;text-align: right;"></asp:Label>
</td>
<td>
<asp:TextBox ID="Model" runat="server" Height="15px" Width="176px" Text="FH(4)" BackColor="#FFFFCC"
CssClass="MyDropBox" AutoPostBack="True" ForeColor="#666666" ReadOnly="True"></asp:TextBox>
<asp:Label ID="StarLabel2" runat="server" Font-Names="Arial" Font-Size="Medium"
ForeColor="#333333" Width="1em"
style="text-align: left;" Text="*"></asp:Label>
</td>
<td>
<asp:RequiredFieldValidator ID="ModelValidator" runat="server" ErrorMessage="Basic Search: Model is required"
ControlToValidate="Model" InitialValue="" ForeColor="Red" Width="15em" CssClass="ErrorMessage"
Font-Size="Small"></asp:RequiredFieldValidator>
</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
</td>
</tr>
<tr>
<td>
<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<table>
<tr>
<td>
<asp:Label ID="KTXLabel" runat="server" Text=" Emission level :"
Font-Names="Arial" Font-Size="Medium"
ForeColor="#333333" CssClass="MyLabel" Width="8em"
style="margin-right: 1em;text-align: right; margin-left: 0px;"></asp:Label>
</td>
<td>
<asp:DropDownList ID="KTX" runat="server" BackColor="#FFFFCC" ForeColor="#666666"
Height="21px" Style="margin-left: 0px" Width="182px" OnSelectedIndexChanged="KTX_SelectedIndexChanged"
CssClass="MyDropBox" DataTextField="text" DataValueField="value" AutoPostBack="True">
</asp:DropDownList>
<asp:Label ID="Label1" runat="server" Font-Names="Arial" Font-Size="Medium"
ForeColor="#333333" Width="1em"
style="text-align: left;" Text="*"></asp:Label>
</td>
<td>
.........
..........
</ContentTemplate>
</asp:UpdatePanel>
<div style="width: 123px; margin-left: 7px; z-index: inherit;">
<asp:Button ID="getURLButton" runat="server" Height="32px" OnClick="getURLButton_Click"
Text="Submit" Width="134px" BackColor="#DD5800" BorderColor="Gray" Font-Bold="True"
Class="MyButton" Font-Size="Large" ForeColor="#4E4E4E" />
</div>
<br />
</div>
</form>

ASP.NET Repeater Control Checkbox issue

Overview: Clicking on text of first CheckBox in a repeater control clicks the last one. I know why this is happening; association of label tag with element id chkMarkedForDeletion and when that label is clicked it selects the last CheckBox, as all the CheckBoxes have same ID.. damn you repeater control!! I am wondering if there is any way to avoid this? Easy way would be to create individual labels and associate correctly to each CheckBox but that defeats the supposed default behaviour of a CheckBox.
Repeater code:
<asp:Repeater ID="childNodesDataRepeater" runat="server">
<ItemTemplate>
<table style="width: 100%;" cellpadding="0" cellspacing="0" border="0">
<tr>
<td style="width: 200px;">
<asp:CheckBox ID="chkMarkedForDeletion" runat="server" EnableViewState="true" Text="Remove"
Checked='<%# DataBinder.Eval(Container.DataItem, "IsMarkedForDeletion") %>' />
</td>
<td>
</td>
<td style="width: 200px;">
<asp:CheckBox ID="chkHighImpactCause" runat="server" EnableViewState="true" Text="High Impact Cause"
Checked='<%# DataBinder.Eval(Container.DataItem, "IsHighPriority") %>' />
</td>
</tr>
<tr>
<td colspan="3">
<asp:Label ID="header002" runat="server" Text="What caused this problem?" />
</td>
</tr>
<tr>
<td colspan="3">
<asp:TextBox ID="txtProblemCausedBy" runat="server" EnableViewState="true" Width="100%"
Text='<%# DataBinder.Eval(Container.DataItem, "Description") %>' /><br />
</td>
</tr>
<tr>
<td colspan="3" style="height: 5px;">
<hr />
<asp:HiddenField ID="nodeIdentifier" runat="server" EnableViewState="true" Value='<%# DataBinder.Eval(Container.DataItem, "AnalysisID") %>' />
</td>
</tr>
</table>
</ItemTemplate>
</asp:Repeater>
Generated HTML Code for CheckBox:
<INPUT id=chkMarkedForDeletion type=checkbox name=TabContainer$tabProblemResolution$frmProblemResolution1$childNodesDataRepeater$ctl00$chkMarkedForDeletion>
<LABEL for=chkMarkedForDeletion>Remove</LABEL>
...
...
<INPUT id=chkMarkedForDeletion type=checkbox name=TabContainer$tabProblemResolution$frmProblemResolution1$childNodesDataRepeater$ctl02$chkMarkedForDeletion>
<LABEL for=chkMarkedForDeletion>Remove</LABEL>
Issue:
Thanks,
Abhi
Make sure the ClientIDMode on the repeater is not set to "Static".
This setting is inheritable from the parent, which goes all the way up to web.config. So if you have to set the ClientIDMode explicitly on the repeater, it means that some parent overrides the default (Predictable) to "Static".

Using ajax calendar extension to update server side chart range

This may be a long shot, but I'm trying to use the client side ajax calendar to select a range of dates for the x-axis of my server side chart. I have both controls set up, I'm just not sure how to get them to communicate with each other or if it's even possible.
This is what I have so far:
<table>
<tr>
<td>
Start Date
</td>
<td>
<asp:TextBox ID="StartDateTextBox" runat="server"></asp:TextBox>
<ajaxToolkit:CalendarExtender ID="StartCal" runat="server"
TargetControlID="StartDateTextBox">
</ajaxToolkit:CalendarExtender>
</td>
<td>
End Date
</td>
<td>
<asp:TextBox ID="EndDateTextBox" runat="server"></asp:TextBox>
<ajaxToolkit:CalendarExtender ID="EndCal" runat="server" TargetControlID="EndDateTextBox">
</ajaxToolkit:CalendarExtender>
</td>
</tr>
<tr>
<td colspan="4">
<asp:Chart ID="TrendChart" runat="server" Width="800px" Height="400px">
<Series>
<asp:Series Name="Trend" ChartType="Line">
</asp:Series>
</Series>
<ChartAreas>
<asp:ChartArea Name="ChartArea1" Area3DStyle-Enable3D="true">
</asp:ChartArea>
</ChartAreas>
</asp:Chart>
</td>
</tr>
<tr>
<td align="center" colspan="4">
<asp:Button ID="TrendChartButton" runat="server" Text="Export To CSV"
CommandArgument="TrendChart" onclick="OverviewChartButton_Click" />
</td>
</tr>
</table

Read textbox from ASP.net page that repeated n times

I have an asp.net web page that's has a number of controls that are repeated according to number of records retrieved from the database, and I wanna read the values of those text boxes after users enter values in them, so please if anyone can help me on this issue.
I have an example of my work
<% System.Data.SqlClient.SqlDataReader myDReader = myDatabaseConnector.getDataFromDBAsSQLDataReader("SELECT * from students);
while(myDReader.Read())
{ %>
<asp:TextBox ID="txtCourseInfo" Test="" EnableViewState="false" CssClass="dataEntrySearchDataText" ReadOnly="true" runat="server"></asp:TextBox>
<% } %>
This a sample of what I have mean from my question in which I want to retrieve the value of txtCourseInfo in my C# code behind
You could use a Repeater to do this:
<asp:repeater id="rptCourses" runat="server" DataSourceID="dsCourseInfo"
<ItemTemplate>
<asp:TextBox ID="txtCourseInfo" Text='<%#Eval("StudentName")#%>' EnableViewState="false" CssClass="dataEntrySearchDataText" ReadOnly="true" runat="server"></asp:TextBox>
</ItemTemplate>
</asp:Repeater>
<asp:sqldatasource id="dsCourseInfo"
ConnectionString="<%$ ConnectionStrings:YourConnectionString %>"
Select Command="Select * from Students">
</asp:sqldatasource>
That's all you need. from code behind you can iterate through the controls on the repeater and grab the information.
Notice the Eval expression on the text field. I used "StudentName" as an example, but you should use one of the column names returned by the select statement
Additional comments:
Don't do select * from ... It's a bad practice in many respects. Always specify the columns you need, even if you need all.
I realize that you disable viewstate on the textbox. I don't know the reason for doing this but be aware that the info won't be persisted on subsequent postbacks unless you enable it on the control.
UPDATE
Yes, you can have tables inside repeaters. Look at the example below:
<ItemTemplate>
<table runat="server" style="color: White; background-color: #3A4F63;" visible="false"
id="headerTable">
<tr>
<td colspan="3" align="center">
<asp:Label ID="headerTitle" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td style="width: 200px; background-color: #3A4F63; color: White;">
Image
</td>
<td style="width: 200px;">
Studen Name
</td>
<td style="width: 200px;">
Birth Date
</td>
</tr>
</table>
<table>
<tr>
<td style="width: 200px;">
<asp:Image ID="img" runat="server" ImageUrl='<%#Eval("ImageUrl") %>'></asp:Image>
</td>
<td style="width: 200px;">
<asp:Label ID="lblName" runat="server" Text='<%#Eval("Name") %>'></asp:Label>
</td>
<td style="width: 200px;">
<asp:Label ID="lblBirthDate" runat="server" Text='<%#Eval("BirthDate") %>'></asp:Label>
</td>
</tr>
</table>
</ItemTemplate>

Categories

Resources