|
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
天气常如二三月,花技不断四时春。
|
|
|
|
|
Hello,
I have a website where customers can register for classroom training. After answering all the questions, I'd like asp.net to send a calendar notice to the users inbox. From what I've seen, I have to attach an ics file that represents an iCalendar. I'm successfully sending emails to the customers...I just have to find out how to add the ics attachment and set the parameters (e.g. remind the customer 24 hrs prior to training day, day of training, etc...).
My users are using Outlook 2003 and greater. I'm using asp.net 2.0. Any ideas?
|
|
|
|
|
Hi all,
I have a GridView (grv) that contain a HyperLinkField ( "MyLink" ).
I have a DataTable (dt) that contain data for GridView. ( I don't use SqlDataSource )
When i click "MyLink", "MyLink"'s NavigateUrl will be Default.aspx?id=param1&idU=param2.
How could i do that?
|
|
|
|
|
You can do it easily in Mygridview_OnRowDataBound event. While binding the grid this event fire on row level then just get the id & idU from other cell and build url string then set it to the Your Link NavigateURL.
Parwej Ahamad
g.parwez@gmail.com
|
|
|
|
|
I am using a GridView to display a list of images. I am trying to have it where I click on an icon within the datagrid to change the url of a another image. Basically I want the selector effect on the image and to get the image url from the icon. Below is the code for the GridView, any help would be great. Thanks.
asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1"
AllowPaging="True" GridLines="None" PageSize="4" ShowHeader="False"
AutoGenerateColumns="False" OnLoad="GridView1_Load" SelectedIndex="0">
Columns>
asp:TemplateField>
ItemTemplate>
asp:ImageButton ID="iconBtn" ImageUrl='<%# Eval("File_Name", "~/images/icon/{0}") %>' runat="server"/>
/ItemTemplate>
/asp:TemplateField>
/Columns>
PagerSettings Mode="NextPrevious"
NextPageImageUrl="~/images/nav_next.jpg" PageButtonCount="4"
PreviousPageImageUrl="~/images/nav_back.jpg" />
/asp:GridView>
-- modified at 13:33 Monday 10th September, 2007
|
|
|
|
|
I need to print a flat file or send printer controls to a specified printer
or port (lpt1,lpt2, com1...) in a web page.
Is it possible? How?
I think i need to embed a control but i don´t know how.
I already read this article http://support.microsoft.com/?kbid=322091 but
this is for windows forms and i am working with web forms!
JL
|
|
|
|