|
Hi Brij!
Thanks for the reply. That's a good idea... I think I'll do that for the newer pages.
However, I don't have the budget to change the validation group of this page that we're tracing.
Do you know of a quick (maybe dirty) way of tracing and knowing which validation control is failing?
Thanks again.
Rafferty
|
|
|
|
|
Hi,
I had a procedure which returns 5 result sets. Now i want to export 3 results sets in 1 excel sheet and the remaining 2 resultsets in another excel sheet. Can we do this in C#.net code and how.
Thanks,
Ram
|
|
|
|
|
|
|
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
|
|
|
|
|