|
ASP.NET 2.0 wrote: My requirement is different. I need to have my login name in the login textbox for ex: when i press v then it should display all the user name whose login name starts with v and when I select my login name it should automatically display the password in password textbox and when I press go button it should go to the home page of my site.
I think you will have to do it with javascript code. I don't know as i never did it . but will ping you if i found anything that will help you ...
ASP.NET 2.0 wrote: Hope I have made my self clear?
Yes
ASP.NET 2.0 wrote: Also I would like to know how did u got my name?
Simple in past i answered your many queries with your name VarshaMane then i think you changed your name
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
Will u please help me with the code??
|
|
|
|
|
|
Hi Sandeep,
Thanks for the reply. But I am not getting the value of password textbox. Below is the code which I am using, please let me know where I am wrong.
protected void Page_Load(object sender, EventArgs e)
{
Session["CompanyName"] = "FLAG";
try
{
if (Request.Cookies["RememberMe"] != null)
{
HttpCookie cookie = Request.Cookies.Get("RememberMe");
string emailID = cookie.Values["Email"].ToString();
string password = cookie.Values["Pass"].ToString();
string LoginID = cookie.Values["LoginID"].ToString();
txtId.Value = emailID;
txtPassword.Value = password;
htxtLoginID.Value = LoginID;
}
}
catch(Exception AuthorizationException)
{
}
}
protected void ibtnLogin_Click(object sender, ImageClickEventArgs e)
{
clsFunctions cs = new clsFunctions();
DataSet ds = new DataSet();
String str = "Select LoginId,LoginName ,Password from tbUser where LoginName= '" + txtId.Value + "' and Password ='" + txtPassword.Value + "' and UserGroupId= 1";
ds=cs.Return_Dataset(str,cs.connectionDBcentral() );
lblMessage.Visible = false;
if (ds.Tables[0].Rows.Count > 0)
{
HttpContext.Current.Cache.Insert(txtId.Value, ds.Tables[0].Rows[0][0]);
if (chkRememberMe.Checked)
{
HttpCookie RememberMe = new HttpCookie("RememberMe");
Response.Cookies.Remove("RememberMe");
Response.Cookies.Add(RememberMe);
RememberMe.Values.Add("Email", txtId.Value);
RememberMe.Values.Add("Pass", txtPassword.Value);
RememberMe.Values.Add("LoginID", ds.Tables[0].Rows[0][0].ToString());
DateTime dtExpiry = DateTime.Now.AddDays(2);
Response.Cookies["RememberMe"].Expires = dtExpiry;
Session.Add("Check", "On");
Session.Add("Country", "0");
Session.Add("logname", txtId.Value);
Session.Add("loginId", ds.Tables[0].Rows[0][0]);
Response.Redirect("Home.aspx");
}
else
{
HttpContext.Current.Cache.Insert(txtId.Value, ds.Tables[0].Rows[0][0]);
Session.Add("Check", "On");
Session.Add("Country", "0");
Session.Add("logname", txtId.Value);
Session.Add("loginId", ds.Tables[0].Rows[0][0]);
Response.Redirect("Home.aspx");
}
}
else
{
Session.Add("Check", "Off");
lblMessage.Text = "Invalid LoginName and Password";
lblMessage.Visible = true;
}
}
this code is in .cs file and in HTML i have used:
function setCookies()
{
var txtuname= document.getElementById('txtId');
var txtpass= document.getElementById('txtPassword');
alert(txtpass);
var txtLoginID =document.getElementById('htxtLoginID');
if (document.cookie.length>0)
{
var c_start=document.cookie.indexOf(txtuname.value);
//alert(document.cookie);
//alert("to search txtvalue "+txtuname.value);
alert(c_start);
if (c_start!=-1)
{
c_start=c_start + txtuname.value.length +1 ;
alert(txtuname.value.length +1);
// alert(" start "+c_start);
var c_end=document.cookie.indexOf(";",c_start);
// alert("end "+c_end);
if (c_end==-1)
{
c_end=document.cookie.length;
// alert(c_end);
}
var value= unescape(document.cookie.substring(c_start,c_end));
alert("value "+value);
var arr = new Array(3);
arr= value.split('|',2)
alert("Username "+arr[0]);
alert("Password "+arr[1]);
txtuname.value=arr[0];
txtpass.value=arr[1];
}
else
{
txtpass.value="";
}
}
}
Please help me...
|
|
|
|
|
Hi
Sorry for late reply you can't add password frm server side check the javascript function readCookie() you have to call this function onFocus of password textbox and set the cookies when user looged in
See what you have to do
1) first of all if userName and password are correct then you have to write them in cookies ok
2) Second whenevr user starts to write his username then on pass word text box focus you have to call javascript .
<br />
protected void LoggedBtn_Click1(object sender, EventArgs e)<br />
{<br />
if(CheckCredentials(txtBxUserName,txtBxPassword))<br />
if (CheckBox1.Checked)<br />
{<br />
HttpCookie cookie = new HttpCookie(TxtBxUserName.Text);<br />
cookie.Values.Add("",TxtBxUserName.Text + "|" + TxtBxPassword.Text+";");<br />
cookie.Expires.AddDays(30);<br />
Response.Cookies.Add(cookie);<br />
<br />
<br />
}<br />
<br />
}<br />
TxtBxPassword.Attributes.Add("OnFocus", "javascript:readCookie();");<br />
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
Hey sandeep its working now, but when I enter any other user name and password and then logout it is not store in cookies. Can u please tell me what might be the problem.
Ex: Suppose I first logon as varsha and password also varsha
and do login and logout and when I again login with varsha it shows by password.
But now if i logon as sandeep and password also sandeep and check the checkbox of remember me and do login it gets login but then value in the cookies are varsha.
Can we have the new value in cookies???
|
|
|
|
|
<br />
HttpCookie cookie = new HttpCookie(TxtBxUserName.Text);<br />
cookie.Values.Add("",TxtBxUserName.Text + "|" + TxtBxPassword.Text+";");<br />
It is happening because you need to store the cookies with different name see above code where i have created cookie with name USername and pass it value as "" and password . i think you are creating cookies with same name/key again check whether you are resetting the cookies you should not reset cookies.I hope you got the point
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
I am implementing Logout ie When I logout all the cookies must be removed and when I login with new user name cookies should be replace with that. Here is the code:
Login.asp.cs
protected void Page_Load(object sender, EventArgs e)
{
Session["CompanyName"] = "FLAG";
txtPassword.Attributes.Add("OnFocus", "javascript:readCookie();");
}
protected void ibtnLogin_Click(object sender, ImageClickEventArgs e)
{
clsFunctions cs = new clsFunctions();
DataSet ds = new DataSet();
String str = "Select LoginId,LoginName ,Password from tbUser where LoginName= '" + txtId.Value + "' and Password ='" + txtPassword.Value + "' and UserGroupId= 1";
ds=cs.Return_Dataset(str,cs.connectionDBcentral() );
lblMessage.Visible = false;
if (ds.Tables[0].Rows.Count > 0)
{
HttpContext.Current.Cache.Insert(txtId.Value, ds.Tables[0].Rows[0][0]);
if (chkRememberMe.Checked)
{
HttpCookie RememberMe = new HttpCookie("RememberMe");
RememberMe.Values.Add("", txtId.Value + "|" + txtPassword.Value + ";");
RememberMe.Expires.AddMinutes(2);
Response.Cookies.Add(RememberMe);
Session.Add("Check", "On");
Session.Add("Country", "0");
Session.Add("logname", txtId.Value);
Session.Add("loginId", ds.Tables[0].Rows[0][0]);
Response.Redirect("Home.aspx");
}
else
{
HttpContext.Current.Cache.Insert(txtId.Value, ds.Tables[0].Rows[0][0]);
Session.Add("Check", "On");
Session.Add("Country", "0");
Session.Add("logname", txtId.Value);
Session.Add("loginId", ds.Tables[0].Rows[0][0]);
Response.Redirect("Home.aspx");
}
}
else
{
Session.Add("Check", "Off");
lblMessage.Text = "Invalid LoginName and Password";
lblMessage.Visible = true;
}
}
JavaScript function:
function readCookie()
{
var txtuname= document.getElementById('txtId');
var txtpass= document.getElementById('txtPassword');
if (document.cookie.length>0)
{
var c_start=document.cookie.indexOf(txtuname.value);
if (c_start!=-1)
{
c_start=c_start + txtuname.value.length +1 ;
var c_end=document.cookie.indexOf(";",c_start);
if (c_end==-1)
{
c_end=document.cookie.length;
}
var value= unescape(document.cookie.substring(c_start,c_end));
var arr = new Array(2);
arr= value.split('|',2)
alert(arr[0]);
// alert("Username "+arr[0]);
// alert("Password "+arr[1]);
txtuname.value=arr[0];
txtpass.value=arr[1];
}
else
{
txtpass.value="";
}
}
}
Logout.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
HttpContext.Current.Cache.Remove(Session["logname"].ToString());
Session["Check"] = "off";
//Cache.Remove("RememberMe");
//HttpCookie RememberMe = new HttpCookie("RememberMe");
//RememberMe.Expires = DateTime.Now;
Response.Cookies["RememberMe"].Expires=DateTime.Now;
Session.Abandon();
FormsAuthentication.SignOut();
Response.Redirect("Login.aspx?action=SessionExpired", true);
}
I am not getting how to do.
Thanks again.
|
|
|
|
|
Yes i think there is one more problem need to check that whenever i am bulding and restarting the application causes reset of cookies need to check that one i don't know why it's happenin g
-- modified at 7:19 Tuesday 11th September, 2007
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
Thanks Sandeep, its working fine now. Thanks a lot...
|
|
|
|
|
<br />
HttpCookie cookie = new HttpCookie(TxtBxUserName.Text);<br />
Response.Cookies.Add(cookie);<br />
cookie.Values.Add("",TxtBxUserName.Text + "|" + TxtBxPassword.Text + ";");<br />
Response.Cookies[TxtBxUserName.Text].Expires = DateTime.Now.AddDays(15); <br />
<br /> see this code Sequence should like it
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
Hi All,
I want to change the number format to Local Culture in Java Script by reading culture value from Web Config. I have a function like below,but the following reads the culture from system settings,instead of this i need a code which reads the Culture from the webconfig and changes the format according to that.
function changeculture()
{
var num = new Number(document.getElementById("arun").value);
document.getElementById("arun").value = num.toLocaleString();
}
Best Regards
Arun Kumar
|
|
|
|
|
Hi,
I am using form authentication for my login page.
if the user provides the correct details then only allow the user to member page,
now here the problem is
"If i am clicking the back button of internet explorer, i am coming to the login page and if i am clicking the forward button its taking into the member page" which i dont want to be acess.
Can any body tell me how to solve this problem.
|
|
|
|
|
Disable the Backspace key of ur Browse on home page.
|
|
|
|
|
Hi,
Hope every one is fine. i am using ASP.NET 2.0 to develop an application. i am having problem with master pages. i want to load some links dynamically from database into master page, on main page they look and work fine but when we go to any other page those links disappear. i tried almost every thing i knew but they are not working.
Kindly help me in this issue, Thanks in advance...
Regards,
Affan Ahmad Toor
..................
QUAIDIAN FOR ONCE, QUAIDIAN FOR EVER!
|
|
|
|
|
I think you are not putting those link in Content Placeholder of master page you should not. Again place that code in Page load of master page it should work ... Can you post the your Master page code ?
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
Hi..
I am developing a web application which needs pop up windows. I have used the javascript showModalDialog to display pop up in IE. But what is equal method to display a pop up window in Firefox
Thanks In Advance
Mahesh.J
|
|
|
|
|
Instead of that you should use window.open(......) with many parameters
Check this method
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
hi all
i have some code this code will read image on database and Export to file Word
string strLinkMap = "http://" + strHost + strParth + "/Print/" + "ReadImageInDatabase.aspx?typepage=" + strTypePage;
StringBuilder strb = new StringBuilder();
strb.Append("\t\t\t\n");
strb.Append("\t\t\t\t\n");
strb.Append("\t\t\t\t\t\n");
strb.Append("\t\t\t\t\n");
strb.Append("\t\t\t\n");
strb.Append("");
strb.Append("\t\t\t\t\t | \n");
ExportWord(strb.ToString());
And I have Function Export()
private void ExportWord(string strhtmldemo)
{
string html = strhtmldemo;
Response.Cache.SetExpires(DateTime.Now.AddSeconds(1));
Response.Clear();
Response.AppendHeader("content-disposition","attachment;filename=FileName.doc");
Response.Charset = "";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = "application/vnd.ms-word";
this.EnableViewState = false;
Response.Write("\r\n");
Response.Write(html);
Response.End();
}
but it have Exception
Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack.
When i dont Export this image show is normal
Some body help me ???
|
|
|
|
|
Hello All,
I a haveing doubt on ...
I am having one form it contains four fields
like user no, name, desg, dob so when i insert these
fields i dont want update in database it update in dataset
when i reterive data from dataset the dataset data it will
shown in gridview .
How i have to apporach please suggest me how to do the
functionality Insert/Update/Delete on dataset to reduce the load on database.
So kindly explain me step step process give me sample progarm its more helpful to me..
Many Thanks
Vijay
|
|
|
|
|
i think you want to store that data only in Dataset not in database. You can put that it quite simple .. How much data is present in the dataset ? (how many users data present in dataset a perticular instant ) if it is only one then you can change the data at any time ... Whats the problem are you facing ?
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
Hello Sandeep,
I dont know how to approach this concept
can u give good example on this.
Many Thanks
vijay
|
|
|
|
|
May be some what like this u can try:
Here I have dataset ds which has some records and I need delete some of them form the output of the Query and use the updated dataset ds.
DataRow objDR;
foreach (DataRow dr in ds.Tables[0].Rows)
{
DataSet ds1 = new DataSet();
cmd1.CommandText = ""; //My Query
SqlDataAdapter adpt2 = new SqlDataAdapter(cmd1);
adpt2.Fill(ds1);
if (ds1.Tables[0].Rows.Count <= 0)
{
dr.Delete();
}
else
{
objDR = objDT.NewRow();
}
ds1.Clear();
}
adpt.Update(ds);
ds.AcceptChanges();
Hope this helps u??
|
|
|
|
|
Hello,
my requirement is if we have filled the form the data display in gridview
in this gridview we can edit the fields and delete the fields but it will not
update in database we have to give one save option if we click that all updated data will save in database.
so kindly guide using dataset how i can do this.
Many Thanks
Vijay
|
|
|
|
|
Hi everyone,
My company has a website, use ms sql server. One table has more than 1000000 records.
When users search data from this table(such as search records which contain the word "school" in NewsTile field.
And the server often occurred deadlock error.
How can I improve it?
Thanks.
P.S. The table has these fields:
NewsID
NewsTitle
NewsContent
NewsClickTimes
NewsInsertTime
=========================================
Make friends with you all.
My Blog, welcome
天气常如二三月,花技不断四时春。
|
|
|
|
|