Click here to Skip to main content
15,889,808 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,

i stuck on this since yesterday.i dont know what i done wrong.everything seems fine.
the page is working fine until i add login page.when i insert username and password then the page redirect to home page.but when i want to insert date(using ajax extender) nothing happen.suppose calender extender appear when i click the textbox.pls help me.i really dont have idea on this problem.



thanks
musiw.
Posted
Comments
Pankaj Nikam 22-Jul-12 1:54am    
Please post the code you have written. We cannot see what results are you getting just by the question.
musiw 22-Jul-12 2:54am    
login page code behind

protected void Button1_Click(object sender, EventArgs e)
{
// Initialize FormsAuthentication, for what it's worth
FormsAuthentication.Initialize();

// Create our connection and command objects
SqlConnection myConnection = new SqlConnection(connectionString);
string sql = "SELECT roles FROM users where empid = '" + empid.Text + "' and pwd = '" + pwd.Text + "'";
SqlCommand cmd = new SqlCommand(sql, myConnection);
SqlDataAdapter adp = new SqlDataAdapter(sql, myConnection);
DataTable ds = new DataTable();
adp.Fill(ds);
// Fill our parameters
cmd.Parameters.AddWithValue("@empid", empid.Text);
cmd.Parameters.AddWithValue("@pwd", pwd.Text);

// Execute the command
myConnection.Open();
SqlDataReader reader = cmd.ExecuteReader();
if (reader.HasRows)
{
while (reader.Read())
{

// Create a new ticket used for authentication
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
1, // Ticket version
empid.Text, // Username associated with ticket
DateTime.Now, // Date/time issued
DateTime.Now.AddMinutes(30), // Date/time to expire
true, // "true" for a persistent user cookie
reader.GetString(0), // User-data, in this case the roles
FormsAuthentication.FormsCookiePath);// Path cookie valid for

}
}
else
{
// Never tell the user if just the username is password is incorrect.
// That just gives them a place to start, once they've found one or
// the other is correct!
lblerror.Text = "Username / password incorrect. Please try again.";
//lblerror.Visible = true;


}

reader.Close();
string roles;
roles = cmd.ExecuteScalar().ToString();
//label_role.Text = roles;
if (ds.Rows.Count != 0)
{

Session["username"] = empid.Text;

if (roles == "admin,user")
{
Server.Transfer("Home.aspx");
}
//else if (roles == "manager,user")
//{
//Server.Transfer("Manager/Home.aspx");
//}
else
{
Server.Transfer("Insert.aspx"); //("~/User/userHome.aspx");
}
}
myConnection.Close();
}
musiw 22-Jul-12 2:56am    
home.aspx

<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">


<asp:Panel ID="Panel2" runat="server" Width="95%">
<table class="style1">
<tr>
<td class="style4">
<asp:Label ID="Label18" runat="server" Font-Names="Arial" Font-Size="Medium"
Text="Task:">
</td>
<td>
<asp:TextBox ID="TextBox1" runat="server" Width="80%" Font-Names="Arial"
Font-Size="Small">
</td>
</tr>
<tr>
<td class="style4">
<asp:Label ID="Label19" runat="server" Font-Names="Arial" Font-Size="Medium"
Text="PIC (Person in charge):" >
</td>
<td>
<asp:ListBox ID="ListBox1" runat="server" Width="80%" SelectionMode="Multiple">
<asp:Label ID="Label26" runat="server" Font-Names="Arial" Font-Size="Small"
Text="Press Ctrl to select multiple">
</td>
</tr>

<tr>
<td class="style4">
<asp:Label ID="Label20" runat="server" Font-Names="Arial" Font-Size="Medium"
Text="Start Date:" >
</td>
<td align="left">
<asp:TextBox ID="TextBox3" runat="server" Font-Names="Arial" Font-Size="Small" >

<asp:CalendarExtender ID="TextBox3_CalendarExtender" runat="server"
Enabled="True" Format="dd/MM/yyyy" PopupPosition="Right"
TargetControlID="TextBox3">


</td>
</tr>
<tr>
<td class="style4">
<asp:Label ID="Label21" runat="server" Font-Names="Arial" Font-Size="Medium"
Text="End Date:">
</td>
<td align="left">
<asp:TextBox ID="TextBox4" runat="server" Font-Names="Arial" Font-Size="Small" >

<asp:CalendarExtender ID="TextBox4_CalendarExtender" runat="server"
Enabled="True" Format="dd/MM/yyyy" TargetControlID="TextBox4">


</td>
</tr>
<tr>
<td class="style4">
<asp:Label ID="Label22" runat="server" Font-Names="Arial" Font-Size="Medium"
Text="Status/Remarks:">
</td>
<td>
<asp:TextBox ID="TextBox5" runat="server" TextMode="MultiLine" Width="80%"
Font-Names="Arial" Font-Size="Small" Height="100px">
</td>
</tr>
<tr>
<td class="style4">
 </td>
<td align="left">
<asp:Label ID="Label13" runat="server" ForeColor="
Pankaj Nikam 22-Jul-12 7:36am    
Code is looking fine. You could have used the improve question and posted the code. Its barely readable here. Anyway what error are you getting?
musiw 22-Jul-12 11:40am    
no error.it just calendar extender didnt appear.i dont know whats wrong with my login page.after i login the home page which has textbox to insert date from calendar extender(ajax toolkit) didnt appear.didnt show up.

but the textbox which i bind to gridview working fine.the calendar extender is show up when i click the textbox to insert a date.

register assembly like this.Then may be problem your solve.

VB
<%@ Register Assembly="CrystalDecisions.Web, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"
    Namespace="CrystalDecisions.Web" TagPrefix="CR" %>
 
Share this answer
 
Comments
Pankaj Nikam 22-Jul-12 9:41am    
What has CrystalReports to do with the problem???
Kaushik Saha from Kolkata,India 22-Jul-12 9:51am    
I don't know what you are asking.
This problem arise before.
Then we declare this.
After that This problem is solved and work properly.
Pankaj Nikam 23-Jul-12 2:45am    
I am asking that what effect does the CrystalReports import causes it to fix? The user is not at all mentioned anywhere that he is using CrystalReports... Can you exactly explain how it solved the problem?
musiw 22-Jul-12 17:41pm    
i already try.but no luck. it seems like when i remove the roles=com.executescalar.to string...then it works.but if its there the problem rise. i dont know whats the problem with my code at the roles part.

basically i want to create login with roles
I believe that the issue might be because of
C#
Server.Transfer
. Try using
C#
Response.Redirect
instead of
C#
Server.Transfer
in the Roles part of your code. If it does not help, please mention in the comment, I will modify the answer and solve it in another way.
 
Share this answer
 
Comments
musiw 25-Jul-12 2:30am    
yes its true.i manage to find it myself.i late to open your answer.thanks anyway! if you dont mind.. why is it this happen?i dont understand
Pankaj Nikam 25-Jul-12 3:32am    
I believe that it was because the login page did not have any ToolkitScriptManager on it... It contains the essential scripts required for the AJAXControlToolkit to perform. As it was not loaded, it failed to show the Extender.

And thanks for marking it as answer :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900