|
|
|
Dear sir,
==>I had A login Page.
==> Every User Will Access the application After The Successfull Login.
==> After Successfull Login Im Storing The Username In a Sesssion.
==> Because I Have To Use The Username In Several Pages in my webapplication.
==> until this i had no problem.
==> now the probelm arised because of the following case..
==> let the user 'A' be logged on to the application and working.
==> the the session will store the username of 'A'.
==> the problem is If another user 'B' logged on to the application,then the session is overwritted by the by the 'B's user name and i m losing the 'A's user name which is stored previously in the session.
==>Now what i have to know is Is there Any Way to create a dynamic session which means if a user logged on then a session to be created for him independent of othe users..
thanks in advance.
vishnu.
|
|
|
|
|
Sessions are independent, for each user in each browsing session. Try logging in as user A in IE, then as user B in Firefox and you'll see all is well. But of course only one user can be logged in on the same computer using ther same browser at the asme time.
|
|
|
|
|
Dear Sir,
First Of All Thanks For Replying me. Now Actually My Problem Is Suppose If The User 'A' Is logged on to the system "A"(for ex). Now If The Same User 'A' HAs Logged On to Another System say "B" then Im Prompting That "You are Already logged on another system.do you want to end that session?" if the user clicks ok then i have to end the session of user "A" who is logged on to the system "A". now he should logged on to the system "B". Is there Any way to solve my problem?
Thanking You Sir,
vishnu.
|
|
|
|
|
First thing, you have very wrong Idea about session.
Session object is unique for every user.means, data stored by a user in session would not be override by another user's session data data.
You must be doing something wrong.
For details, have a look one good link on CP itself.
Exploring Session in ASP.Net
|
|
|
|
|
vishnukamath wrote: the problem is If another user 'B' logged on to the application,then the session is overwritted by the by the 'B's user name and i m losing the 'A's user name which is stored previously in the session
Hi,
Are you sure that you are using Session object (which is for each users) and not Application state (which is common for all users or sessions)
Eg:
Session["UserName"] = txtUserName.Text;
Application["Message"] = "Message to All users";
|
|
|
|
|
Hi,
Where can I downloadthe UFrame from? there is not download release available on CodePlex? any idea? or any idea of simillar control?
Thanks
|
|
|
|
|
jrahma wrote: Where can I downloadthe UFrame from? there is not download release available on CodePlex? any idea? or any idea of simillar control?
Do you mean this[^] one? If yes then the page has link for Codeplex too. Nice one.
thatraja |Chennai|India|
Brainbench certifications Down-votes are like kid's kisses don't reject it Do what you want quickly because the Doomsday on 2012
|
|
|
|
|
I have the following code which simply display a timer within the UpdatePanel but the problem, I have another UpdatePanel [LoginPanel] in the page which should also Update always but with a different criteria .. here is the problem.. the LoginPanel is getting refreshed withthe time of the CurrenTTimePanel as well? why is that?
<dxt:ASPxTimer ID="timerClock" runat="server" Interval="1000" OnTick="timerClock_Tick" />
<asp:UpdatePanel runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="timerClock" />
</Triggers>
<ContentTemplate>
<asp:Table runat="server" Width="120" BorderWidth="0" CellPadding="0" CellSpacing="0">
<asp:TableRow>
<asp:TableCell HorizontalAlign="Center" VerticalAlign="Middle"><dxe:ASPxImage ID="imageFlag" runat="server" ImageUrl="~/images/flags/ar-BH.gif" /></asp:TableCell>
<asp:TableCell HorizontalAlign="Center" VerticalAlign="Middle" Width="100%"><dxe:ASPxLabel ID="lblCurrentTime" runat="server" Font-Bold="true" Text="Loading.." /></asp:TableCell>
</asp:TableRow>
</asp:Table>
</ContentTemplate>
</asp:UpdatePanel>
|
|
|
|
|
Change the value for Mode Always to Conditional to LoginPanel
thatraja |Chennai|India|
Brainbench certifications Down-votes are like kid's kisses don't reject it Do what you want quickly because the Doomsday on 2012
|
|
|
|
|
Hi,
I am developing a simple web application in ASP.net.
I would like to know in database connection if I face with error how I should show it. do I have to use java script? because unlike desktop application can't use message box.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Data;
using System.Data.Sql;
using System.Configuration;
namespace Test.DataAccessLayer
{
public class PersonDataAccess
{
SqlConnection Conn = new SqlConnection(ConfigurationManager.ConnectionStrings["HostelConnectionString"].ConnectionString);
public void insert()
{
try
{
Conn.Open();
}
catch (Exception ex)
{
????????????????????????????????????????????????????????????????????????????
}
}
}
}
|
|
|
|
|
you don't have to use javascript, you can catch the exception and assign ex.message to a label's text.
if you still want to use a message box, you do have to use javascript(you can download a exist class)
|
|
|
|
|
you can show your message, by using Java script alert Message
as
Response.Write("<script>alert('Your Message')</script>");
or you can also use custom error concept to show your message while a error generate
follow link Custom Errors in ASP.NET[^]
|
|
|
|
|
It is not a good practice, to show exception errors in javascript alert.
Better , if you find any exception , show in that page or redirect to some other error page
|
|
|
|
|
Brij wrote: Better , if you find any exception , show in that page or redirect to some other error page
Ya i knew it, that's why i have already describe or refer a link about custom error which works as you say.
|
|
|
|
|
RaviRanjankr wrote: Ya i knew it, that's why i have already describe or refer a link about custom error which works as you say
Obiously, you must be knowing. I just suggested , not to use JS alert.
|
|
|
|
|
Brij wrote: Obiously, you must be knowing. I just suggested , not to use JS alert.
whatever, thanks for your guidance or suggestion.
|
|
|
|
|
first, i'm sorry i'm newbie here and newbie in aspnet. i learn some code from ebook but it's not working. and i'm really sorry too because my english is bad.
when i debug my project its working fine, and i try to add item to my shopping cart its not show any error but the button do not work, its ike the product page only reload. i hope i can find the answer here.
thanks for help.
here the code
CartAccess.cs
using System;
using System.Web;
using System.Data;
using System.Data.Common;
public class CartAccess
{
public CartAccess()
{
}
private static string shoppingCartId
{
get
{
HttpContext context = HttpContext.Current;
string cartId;
{
if (context.Request.Cookies["Delta_CartID"] != null)
{
cartId = context.Request.Cookies["Delta_CartID"].Value;
return cartId;
}
else
{
cartId = Guid.NewGuid().ToString();
HttpCookie cookie = new HttpCookie("Delta_CartID", cartId);
int howManyDays = deltaconfig.CartExpireDays;
DateTime currentDate = DateTime.Now;
TimeSpan timeSpan = new TimeSpan(howManyDays, 0, 0, 0);
DateTime expirationDate = currentDate.Add(timeSpan);
cookie.Expires = expirationDate;
context.Response.Cookies.Add(cookie);
return cartId.ToString();
}
}
}
}
public static bool AddItem(string bookId)
{
DbCommand comm = DataAccess.CreateCommand();
comm.CommandText = "AddItem";
DbParameter param = comm.CreateParameter();
param.ParameterName = "@CartID";
param.Value = shoppingCartId;
param.DbType = DbType.String;
param.Size = 36;
comm.Parameters.Add(param);
param = comm.CreateParameter();
param.ParameterName = "@BookID";
param.Value = bookId;
param.DbType = DbType.Int32;
comm.Parameters.Add(param);
try
{
return (DataAccess.ExecuteNonQuery(comm) != -1);
}
catch
{
return false;
}
}
public static bool UpdateItem(string bookId, int cquantity)
{
DbCommand comm = DataAccess.CreateCommand();
comm.CommandText = "UpdateItem";
DbParameter param = comm.CreateParameter();
param.ParameterName = "@CartID";
param.Value = shoppingCartId;
param.DbType = DbType.String;
param.Size = 36;
comm.Parameters.Add(param);
param = comm.CreateParameter();
param.ParameterName = "@BookID";
param.Value = bookId;
param.DbType = DbType.Int32;
comm.Parameters.Add(param);
param = comm.CreateParameter();
param.ParameterName = "@CQuantity";
param.Value = cquantity;
param.DbType = DbType.Int32;
comm.Parameters.Add(param);
try
{
return (DataAccess.ExecuteNonQuery(comm) != -1);
}
catch
{
return false;
}
}
public static bool RemoveItem(string bookId)
{
DbCommand comm = DataAccess.CreateCommand();
comm.CommandText = "RemoveItem";
DbParameter param = comm.CreateParameter();
param.ParameterName = "@CartID";
param.Value = shoppingCartId;
param.DbType = DbType.String;
param.Size = 36;
comm.Parameters.Add(param);
param = comm.CreateParameter();
param.ParameterName = "@BookID";
param.Value = bookId;
param.DbType = DbType.Int32;
comm.Parameters.Add(param);
try
{
return (DataAccess.ExecuteNonQuery(comm) != -1);
}
catch
{
return false;
}
}
public static DataTable GetItem()
{
DbCommand comm = DataAccess.CreateCommand();
comm.CommandText = "GetItem";
DbParameter param = comm.CreateParameter();
param.ParameterName = "@CartID";
param.Value = shoppingCartId;
param.DbType = DbType.String;
param.Size = 36;
comm.Parameters.Add(param);
DataTable table = DataAccess.ExecuteSelectCommand(comm);
return table;
}
public static decimal GetTotalAmount()
{
DbCommand comm = DataAccess.CreateCommand();
comm.CommandText = "GetTotalAmount";
DbParameter param = comm.CreateParameter();
param.ParameterName = "@CartID";
param.Value = shoppingCartId;
param.DbType = DbType.String;
param.Size = 36;
comm.Parameters.Add(param);
return Decimal.Parse(DataAccess.ExecuteScalar(comm));
}
public static int CountOldCarts(byte days)
{
DbCommand comm = DataAccess.CreateCommand();
comm.CommandText = "CountOldCarts";
DbParameter param = comm.CreateParameter();
param.ParameterName = "@Days";
param.Value = days;
param.DbType = DbType.Byte;
comm.Parameters.Add(param);
try
{
return Byte.Parse(DataAccess.ExecuteScalar(comm));
}
catch
{
return -1;
}
}
public static bool DeleteOldCarts(byte days)
{
DbCommand comm = DataAccess.CreateCommand();
comm.CommandText = "DeleteOldCarts";
DbParameter param = comm.CreateParameter();
param.ParameterName = "@Days";
param.Value = days;
param.DbType = DbType.Byte;
comm.Parameters.Add(param);
try
{
DataAccess.ExecuteNonQuery(comm);
return true;
}
catch
{
return false;
}
}
}
ShoppingCart.aspx.cs
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class ShoppingCart : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Populate();
}
}
private void Populate()
{
DataTable dt = CartAccess.GetItem();
if (dt.Rows.Count == 0)
{
gridview.Visible = true;
Updatebtn.Enabled = false;
TotalAmount.Text = String.Format("{0:c}", 0);
}
else
{
gridview.DataSource = dt;
gridview.DataBind();
gridview.Visible = true;
Updatebtn.Enabled = true;
decimal amount = CartAccess.GetTotalAmount();
TotalAmount.Text = String.Format("{0:c}", amount);
}
}
protected void continuebtn_Click(object sender, EventArgs e)
{
Response.Redirect("/");
}
}
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class Product : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string bookId = Request.QueryString["BookID"];
BookDetails bd = CatalogAccess.GetBookDetails(bookId);
if (bd.Name != null)
{
Populate(bd);
}
else
{
Server.Transfer("ProductNotfound.aspx");
}
}
private void Populate(BookDetails bd)
{
titleLabel.Text = bd.Name;
descriptionLabel.Text = bd.Description;
stockLabel.Text = Convert.ToString(bd.Quantity);
priceLabel.Text = String.Format("{0:c}", bd.Price);
authorLabel.Text = bd.Author;
productImage.ImageUrl = "BookImage/" + bd.Image;
this.Title = deltaconfig.SiteName + bd.Name;
}
protected void AddToCartButton_Click(object sender, EventArgs e)
{
string bookId = Request.QueryString["BookID"];
CartAccess.AddItem(bookId);
}
}
and thanks again
|
|
|
|
|
Having all of the methods of the cart as static is a bad idea. You are also throwing away the return values. If CartAccess.AddItem returns a bool you should be doing something with it. It could be as simple as setting the text of a label with "added to cart" or "oops something bad happened". I am guessing you would be getting a false and that it has something to do with your database connection. To get detailed info about what went wrong, either remove the try/catch around the DataAccess calls, or in the catch, change it to catch(Exception ex) and set a label with ex.Message.
Your English is not bad at all.
|
|
|
|
|
5 for you because of your etiquette and good manners!!!
|
|
|
|
|
Hi,
Just wondering to know, between ADO.net and Dataset which one is better for working with database.
Could you please give me a link for beginner?
thanks a lot
|
|
|
|
|
|
I have to do an module program which downloads pdf files in the client side. Currently, when users download the file, the url of the downloaded file is viewed by the user.
Modification instructed:
1. In the page where the file download is requested, the url of the downloaded file is viewed in the status bar of that web page. Modification is that the status bar should not display the url of the downloaded file. -- This had been corrected and the code has modified accordingly. It is done correctly only for the first page. Blinks how to process this for the second page..
2. Currently, the call for the download page is given along with the filename of the user request. The filename is passed as the querystring. Modification needed is that the url should get rewritten as "~/download.aspx" instead of "~/download.aspx?<filename>".
I came across using "urlrewriter". But don't know how to implement since i feel little confused with the code examples in net.
I'm placing my code for ur assistance. I'm not using webconfig file also.
old try pdf.aspx
****************
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="old try pdf.aspx.cs" Inherits="old_try_pdf" %>
<!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 runat="server">
<title>Try PDF - Download</title>
<style>
.link_text
{
font-family:Tahoma;
font-size:10px;
color:#1d5296;
text-decoration:none;
}
.link_text A
{
font-family:Tahoma;
font-size:11px;
color:#1d5296;
text-decoration:underline;
}
.link_text A:hover
{
color:#ff000c;
text-decoration:underline;
}
.link_text A:active
{
color:#ff000c;
text-decoration:underline;
}
.bullets
{
background-image:url(Bullet.gif);
background-position:center;
width:10px;
height:10px;
display:table-cell;
vertical-align:top;
background-repeat:no-repeat;
}
.display_cell
{
border:solid 1px #e6e7e8;
display:table-cell;
width:355px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<table>
<tr>
<td class='display_cell'>
<asp:Panel runat=server ID="pnl_pdf"></asp:Panel>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
old try pdf.aspx.cs
*******************
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
public partial class old_try_pdf : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Table tb_currency = new Table();
tb_currency.Width = 355;
TableRow tr_currency = new TableRow();
TableCell tc_currency = new TableCell();
Image img_currency = new Image();
HyperLink hlk = new HyperLink();
foreach (string fnames in Directory.GetFiles(@"~\Link 2 Download\pdf"))
{
string fname = null;
tr_currency = new TableRow();
tc_currency = new TableCell();
tc_currency.CssClass = "bullets";
tr_currency.Cells.Add(tc_currency);
tc_currency = new TableCell();
tc_currency.HorizontalAlign = HorizontalAlign.Left;
tc_currency.CssClass = "link_text";
hlk = new HyperLink();
hlk.Target = "_blank";
fname = Path.GetFileNameWithoutExtension(fnames);
hlk.Text = fname;
hlk.Attributes.Add("onMouseOver", "javascript:window.status=''; return true;");
hlk.Attributes.Add("onMouseOut", "javascript:window.status=''; return true;");
hlk.Attributes.Add("onClick", "javascript:window.status=''; return true;");
hlk.NavigateUrl = "~/Old download_pdf.aspx?fn=" + fname;
tc_currency.Controls.Add(hlk);
tr_currency.Cells.Add(tc_currency);
tb_currency.Rows.Add(tr_currency);
}
pnl_pdf.Controls.Clear();
pnl_pdf.Controls.Add(tb_currency);
}
}
Old download_pdf.aspx
*********************
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Old download_pdf.aspx.cs" Inherits="Old_download_pdf" %>
<!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 runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
Old download_pdf.aspx.cs
************************
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Net;
using System.IO;
public partial class Old_download_pdf : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string strMessage = "Wait.... File is downloading....";
this.RegisterStartupScript("SetStatusText", "<script>window.status='" + strMessage + "';</script>");
if (Request.QueryString.Count > 0)
{
string fn = Request.QueryString.Get(0).ToString();
string spath = @"~\pdf\" + fn + ".pdf";
Response.ClearContent();
Response.ClearHeaders();
Response.ContentType = "application/pdf";
Response.AddHeader("Content-Disposition", "attachment; filename=my_test.pdf");
Response.TransmitFile(spath);
Response.End();
}
}
}
Even using register startup variable, in Old_download_pdf.aspx, it is showing the downloaded file url path in status bar of the page Old_download_pdf.aspx. Also we have to rewrite the url from "~/Old download_pdf.aspx?fn=<filename>" as simply "~/Old download_pdf.aspx".
When i tried using a hidden variable, i failed in setting the value of the hidden field during the click event of the dynamically creating hyperlink control.
How to complete this? Thanks in advance.
Regards,
M.Sworna Vidhya
|
|
|
|
|
Hi All,
I just come across a pretty weird behaviour on my VS 2005 and Ajax, basically i am having a master page and a content page. This is the front end html code for the master page:
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="MasterPage.master.cs" Inherits="WebApplication3.MasterPage" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc" %>
<%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
Namespace="System.Web.UI" TagPrefix="asp" %>
<!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 runat="server">
<title>Test Page</title>
<link href="Stylesheet1.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" runat="server">
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<%--<cc:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"></cc:ToolkitScriptManager> --%>
<cc:Accordion ID="Accordion1" runat="server" FadeTransitions="true" SelectedIndex="0"
HeaderCssClass="accordionHeader" ContentCssClass="accordionContent">
<Panes>
<cc:AccordionPane ID="AccordionPane1" runat="server">
<Header>Test Pane 1</Header>
<Content>Test pane 1</Content>
</cc:AccordionPane>
<cc:AccordionPane ID="AccordionPane2" runat="server">
<Header>Test Pane 2</Header>
<Content>Test pane 2</Content>
</cc:AccordionPane>
<cc:AccordionPane ID="AccordionPane3" runat="server">
<Header>Test Pane 3</Header>
<Content>Test pane 3</Content>
</cc:AccordionPane>
</Panes>
</cc:Accordion>
</div>
</form>
</body>
</html>
and this is the front end html code for the content page:
<%@ Page Language="C#" MasterPageFile="~/MasterPage.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication3.Default" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
test
</asp:Content>
but when i try to run it, it always gives me this bloody error:Server Error in '/' Application.
--------------------------------------------------------------------------------
The control with ID 'Accordion1_AccordionExtender' requires a ScriptManager on the page. The ScriptManager must appear before any controls that need it.
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.InvalidOperationException: The control with ID 'Accordion1_AccordionExtender' requires a ScriptManager on the page. The ScriptManager must appear before any controls that need it.
I even dont have this control 'Accordion1_AccordionExtender' on my page, so i dont know what is complaining for.
But when i put the same code in vs 2008, and i use
<cc:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"></cc:ToolkitScriptManager> instead of
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager> it just worked like a charm, i was searching on the internet, quite a few ppl got the same issue, but no one has a resonable answer about it. My AjaxControlToolkit.dll was released at 12/05/2010 and AJAXExtensionsToolbox.dll was released at 13/12/2006. Can someone in here plz shed me a light what could be the issue?Many thanks.
|
|
|
|