|
There Tier Architecture is nothing but breaking your application in different layer like,
1. UI Layer
2. BLL : Business Logic Layer
3. DAL : Data Access Layer
Here is one good article for begineers :
3-Tier Architecture in ASP.NET C#[^]
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
Iam having two tables in database ms sql server ,dept and emp
dept table with fields are as followsdeptno(primary key),deptname,dlocation
emp table with fields are as follows
empno(primary key),empname ,salary,deptno(foriegn key)
in asp.net integrating with c# , when i select deptno in treeview control i want to display deptno with all details about the employes please help
|
|
|
|
|
|
hii all i have a datalist in which i have taken labels and checkboxs.i want that when the user select the checkboxes from any rows.the text of all the selected check box get displayed in a textbox or label.i have also taken a hidden field to found the id of selected row.what is the next step that i shd perform.plz guide.thank's
|
|
|
|
|
Handle the CheckChanged event and the text for the textbox/label in that.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
hiii on which command shud i do this.....can u tell me in brief....
|
|
|
|
|
This is how you cna assign the check changed event handler for the check box:
<asp:CheckBox ID="myCheckBox" runat="server" OnCheckedChanged="CheckChangedHandler"/>
Now, in the code behind, you can access your hidden field to the selected row index and then access it using the Items property.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
hii m getting one more prob when i am trying to debug by code which is written at button click
event but when i click the button the control is not going inside the button click code....
|
|
|
|
|
Are you writing any javascript for the event..!
if yes may be thts the problem..!
if no copy the code in the event and delete the event and add the event and paste the code..!
LatestArticle :Log4Net
Why Do Some People Forget To Mark as Answer .If It Helps.
|
|
|
|
|
|
Its K..! Any Time..!
LatestArticle :Log4Net
Why Do Some People Forget To Mark as Answer .If It Helps.
|
|
|
|
|
Recently I have created a data access layer and business logic layer in a class library (seperate assemblies). I cannot get the edit or delete functionailty to work, the gridview simply posts back leaving the data intact.
I then created a dataset in the app_code portion of my web site and it works fine.
Any idea why it seems like putting this code into its own assembly doesn't work when deleting and editing (but select works fine)?
|
|
|
|
|
Hi,
I am a new user to ASP.NET and VS.NET and I need some help. I am also a new user to CodeProject as well.
I am trying to find a simple way to add a hit counter on a web page (ASP.NET and VB.NET) in VS.NET 2005.
I found this example "Fast ASP.NET Hit Counter with Full Digit Graphic File Support" By JediBaron.
I tried it but something goes wrong. I get this error on line 59:
Dim i As System.Drawing.Image = System.Drawing.Image.FromFile(Server.MapPath(Request("src")))
I really cannot figure out what is wrong and how to correct the problem. Any help will be appreciated.
Thanks.
|
|
|
|
|
This is off the top of my head.
In your global.asax do this
Sub Application_Start(ByVal sender AsObject, ByVal e As EventArgs)
Application("Hits") = 0
EndSub
Sub Session_Start(ByVal sender AsObject, ByVal e As EventArgs)
'Lock the Application for concurrency issues
Application.Lock()
'Increment the counter
Application("Hits") = Application("Hits") + 1
'Unlock the Application
Application.UnLock()
EndSub
Than put this in your web form
<%=application("Hits")%>
times.
|
|
|
|
|
Also he needs to store the hit count in permanent storage, so that even if the application gets restarted, the value Remains..
|
|
|
|
|
Hi Abhishek Sur,
I do want to store the counter hits number in a data store, but cannot figure out how to do it.
I have created a test database (DbTest) in SQL Server 2005 with a Param table and a simple column, NbHits. I can connect to it and display the number on a page. That is it.
I would like my counter to be incremented every time a user visits the main page.
I would also like to know which way is best for a simple personal web site.
Do you know of some links where I could find some example?
Thanks.
|
|
|
|
|
Hi HarrissonB,
This is a great start, but the counter gets reinitialized to 0 every time. There must be a simple way to store it somewhere and read the value from this data source.
Now, I suppose there are many ways to store such a value, in a database (SQL Server, Access, etc.), in a text file or XLM file, and maybe some others.
For a simple personal web site, what would be the best way (KISS method)?
In a text file, would it be safe?
Thanks.
|
|
|
|
|
It will only get set to 0 when the web server is restarted but when the page is reloaded.
|
|
|
|
|
Hi HarrisonB,
The hit counter should never be reinitialized to 0, even when the server goes down. It should read its value from some data store where a start value could be set (<> 0) at the beginning.
I think I can find some code where a xml file can be used. I will look it up and give you an answer as soon as I can.
Thanks for your time.
|
|
|
|
|
Good morning, most of my work is generally client server so some of the basic ASP.NET questions are a pain for me, so forgive me if this is stupid.
I am trying to load an image on the event of clicking a cell in a gridview. The gridview has a button and I am calling the RowCommand to load the picture. The field for the image name is in the gridview, the code looks like this (Basically)
protected void gvRecords_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "View")
{
Int32 rowIndex = Convert.ToInt32(e.CommandArgument.ToString());
string path = @"Images/Foo/images/";
string fileName = gvRecords.Rows[rowIndex].Cells[7].Text;
imgMyRecord.ImageUrl = Server.MapPath(path + fileName);
imgMyRecord.Height = 250;
imgMyRecord.Width = 250;
}
}
I have tried a static reference in the Mappath, but can't get the image to load. The possible caveat to this is that the "Images" folder referred to above is located on another server and is a virtual directory pointing to a UNC path. So I added the Virtual folder in the app folder pointing to \\server\folder.
Where is my issue? Is the setup of the virtual folder wrong or am I just plain old doing it wrong? Or both?
|
|
|
|
|
Examine the HTML source of your page and see exactly what ImageUrl is being created, debug from there.
|
|
|
|
|
Hi,I m having a menubar with 7 menu,designed with css. problem is when form loads first time,3 menu get shifted in 2nd row. but when i refresh page, all 7 menu display in one row which is right.
can anybody guess what is the problem?
|
|
|
|
|
Spurple wrote: can anybody guess what is the problem?
I guess your css is not applying properly. Did you tested with all browser ?
If you are using FF, then install FireBug and test the CSS and all tags, or Copy the View Source of pages first time and then compare with second html code.
You will get to know the cause.
Thanks
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
I am using below code to encrypt and decrypt querystring value .it works fine
but it show nullrefrence exception when
some works not performed in mysite for more than 15-20 minute.
it shows savedKey and savedIV must be non-null." error
I am not analyzing why this error occur .
private static byte[] savedKey = null;
private static byte[] savedIV = null;
public static byte[] key
{
get { return savedKey; }
set { savedKey = value; }
}
public static byte[] IV
{
get { return savedIV; }
set { savedIV = value; }
}
private static void rdGenerateSecretKey(RijndaelManaged rdProvider)
{
if (savedKey == null)
{
rdProvider.KeySize = 256;
rdProvider.GenerateKey();
savedKey = rdProvider.Key;
}
}
private static void rdGenerateSecreInitVector(RijndaelManaged rdProvider)
{
if (savedIV == null)
{
rdProvider.GenerateIV();
savedIV = rdProvider.IV;
}
}
public static string Encrypt(string originalStr)
{
Random RandNum = new Random();
int RandomNumber = RandNum.Next(1000000, 9999999);
originalStr = String.Format("{0}&Random={1}", originalStr, RandomNumber.ToString());
//encode data string to be stored in memory
byte[] originalStrAsBytes = Encoding.ASCII.GetBytes(originalStr);
byte[] originalBytes = { };
// create memory stream to contain output.
using (MemoryStream memStream = new MemoryStream(originalStrAsBytes.Length))
{
using (RijndaelManaged rijndel = new RijndaelManaged())
{
// generate secret ket and save in to vector.
rdGenerateSecretKey(rijndel);
rdGenerateSecreInitVector(rijndel);
if (savedKey == null || savedIV == null)
{
throw (new NullReferenceException("savedKey and savedIV must be non-null."));
}
// Create Encrypt and Stream Objects.
using (ICryptoTransform rdTransform=rijndel.CreateEncryptor((byte[]) savedKey.Clone(),(byte[]) savedIV.Clone()))
{
using (CryptoStream cryptostream =new CryptoStream(memStream,rdTransform,CryptoStreamMode.Write))
{
// write crypto stream data in memeory stream
cryptostream.Write(originalStrAsBytes,0,originalStrAsBytes.Length);
cryptostream.FlushFinalBlock();
originalBytes=memStream.ToArray();
}
}
}
}
// convert encrypted string
string encryptedStr=Convert.ToBase64String(originalBytes);
return(encryptedStr);
}
public static string Decrypt(string encryptedStr)
{
// unconvert encrypted string.
encryptedStr = encryptedStr.Replace(" ", "+");
byte[] encryptedAsBytes = Convert.FromBase64String(encryptedStr);
byte[] intialText = new byte[encryptedAsBytes.Length];
using (RijndaelManaged rijndael = new RijndaelManaged())
{
using (MemoryStream memStream = new MemoryStream(encryptedAsBytes))
{
if (savedKey == null || savedIV == null)
{
throw (new NullReferenceException("savedKey and savedIV must be non-null. "));
}
// Create Decrypt and Stream Objects.
using (ICryptoTransform rdTransform = rijndael.CreateDecryptor((byte[])savedKey.Clone(), (byte[])savedIV.Clone()))
{
using (CryptoStream cryptostream = new CryptoStream(memStream, rdTransform, CryptoStreamMode.Read))
{
// Read decryte string as bytes
cryptostream.Read(intialText, 0, intialText.Length);
}
}
}
// convert byte[] to string
string decryptedStr = Encoding.ASCII.GetString(intialText);
return (decryptedStr);
}
}
public static System.Collections.Hashtable FillQs(HttpRequest request)
{
char[] SepMain = { '&' };
char[] SepSub = { '=' };
string Test = string.Empty;
System.Collections.Hashtable hasTableQueryStringId = new System.Collections.Hashtable();
if (request.QueryString["Q"] != null)
{
string[] Param = Decrypt(request.QueryString["Q"].ToString()).Split(SepMain, StringSplitOptions.RemoveEmptyEntries);
foreach (string str in Param)
{
string[] ParamKey = str.Split(SepSub);
//request.QueryString.Set(request.QueryString[ParamKey[0].ToString()], ParamKey[1].ToString());
//request.QueryString[ParamKey[0].ToString()] = ParamKey[1].ToString();
hasTableQueryStringId.Add(ParamKey[0].ToString(), ParamKey[1].ToString());
}
}
else
{
hasTableQueryStringId.Add("NoAttachments", "NoAttachments");
}
return hasTableQueryStringId;
}
|
|
|
|
|
I would say this sounds like a session timeout.
Try to set a shorter time of period per session in web.config and try to confirm my suggestion.
Greetings
Covean
|
|
|
|