Geeks With Blogs
AzamSharp Some day I will know everything. I hope that day never comes. September 2005 Entries
Using AJAX power in JavaScript Confirmation window
I am pretty sure everyone knows about the JavaScript confirmation window if not you can look at the image below: Anyway, sometimes we need to capture "ok" as well as "Cancel". "Ok" is easy to catch since the server side button click will take place if you click "ok". Catching "cancel" is kinda hard since cancel is only handled on the client side. What if you want to do something when the cancel button is clicked. You can use AJAX to solve this problem. Here is a simple example. Below are the two ......

Posted On Wednesday, September 28, 2005 2:10 AM

Passing values from the child window to the parent window
Sometimes we are in a situation in which we need to pass the values from the Child window to the parent window. Here is a code snippet that does the operation. Parent window: Parent window contains a textbox in which the value will be passed from the child window. And also it contains a linkbutton which is used to open the child window: protected void Page_Load(object sender, EventArgs e) { string openWindow = @"window.open('Child.aspx')"; this.LinkButton1.Attributes... openWindow); } ......

Posted On Tuesday, September 27, 2005 1:36 PM

Finally! back to Houston
Finally, I am back to Houston. Right now the time is 1:26 AM feeling little sleepy. The drive from San Antonio to Houston was not that bad. Took us 3.5 hours and 1 hour to find some food to eat since everything was closed. I hope everyone has safe trip back to Houston or their home town. powered by IMHO ......

Posted On Sunday, September 25, 2005 2:28 AM

This is why the Input string is not in the correct format!
I was answering some questions on the www.asp.net forms where I came across an interesting post which deals with the error "Input string is not in the correct format". The situation was that converting the label text to the integer value. The code that was generating error was: private void FormatTesting() { Label1.Text = "34.45"; try { int myInt = Int32.Parse(Label1.Text); } catch (Exception ex) { lblMsg.Text = ex.Message; } } The reason is that the label text is in the double format since it includes ......

Posted On Friday, September 23, 2005 4:33 PM

Evacuating the hurricane RITA!
Okay, believe it or not but I am writing this post from the back seat of a car. Yes! I am leaving to San Antonio. I still have 150 miles to go and I have only covered 25 miles in 5 hours. The traffic is jam pack. I have no idea when I will be back to Houston again. I am pretty sure that it will take around 15 hours to get to San Antonio from Houston.The hurricane RITA is suppose to come late friday or early saturday. Damn! its hot, its 98 degress and with no air conditioning. UPDATE: Finally after ......

Posted On Thursday, September 22, 2005 9:54 PM

What are your thoughts on outsourcing?
What do you think about outsourcing? Does the work being done in different countries is of good quality? What are your thoughts on this issue? powered by IMHO ......

Posted On Monday, September 19, 2005 11:46 PM

You cannot make Foreign Key relationship on the Temporary Tables
If you are working with the temporary tables than keep in mind you cannot make foreign key relationships to other tables. Check out the T-SQL code below.CREATE TABLE #Person (PersonID int identity(1,1) PRIMARY KEY,FirstName nvarchar(20), LastName nvarchar(20) )CREATE TABLE #Phone(PhoneID int identity(1,1) PRIMARY KEY, PhoneNumber nvarchar(20), PersonID int FOREIGN KEY REFERENCES Person(PersonID) -- Naa cannot do this Dude!!ON DELETE NO ACTION ) powered by IMHO ......

Posted On Monday, September 19, 2005 10:58 PM

Opening a PDF File from Asp.net page
Before I paste the code. I like to thank Longhorn for providing me the code in VB.NET for opening the pdf file. The code is given below: private void ReadPdfFile() { string path = @"C:\Swift3D.pdf"; WebClient client = new WebClient(); Byte[] buffer = client.DownloadData(path); if (buffer != null) { Response.ContentType = "application/pdf"; Response.AddHeader("content... Response.BinaryWrite(buffer); } } powered by IMHO ......

Posted On Sunday, September 18, 2005 11:59 PM

When will this cache object expire?
If you don't put any expiration policy on the Cache object than it can only under certain scenarious. Take a look at the code below where I did not establish any expiration policy for the cache object. private DataSet GetDataSetNoDatabaseDepende... { DataSet ds = null; if (Cache["MyDataSet"] != null) { // This means that Cache object contains Data ds = (DataSet)Cache["MyDataSet"]; } else { // Adds the dependency to the Cache object SqlConnection myConnection = new SqlConnection(GetConnection... ......

Posted On Sunday, September 18, 2005 8:08 PM

Why use Enterprise Library Caching?
I wrote an article on Enterprise Library Caching Block in which I described the use of Caching Block. Few days ago I received an email from a developer asking that what are the advantages of using Enterprise Library Caching Block over the standard caching. If we talk about performance than they are pretty much the same. Actually I will be inclined towards the standard caching since Enterprise Library calls the standard caching under the hood. The main advantage of using the EL Caching is it's easier ......

Posted On Sunday, September 18, 2005 6:00 PM

Playing around with Menu Control in ASP.NET 2.0
Asp.net 2.0 is comming soon ( I mean officially released final version ) and its bringing lots of cool stuff with it. One of the cool controls is tree view control. I spent some time looking into the tree view control. Depending on your requirments you can populate the tree view control using different sources. Populating using the SiteMapDataSource: private void CreateMenuControl() { Menu1.DataSource = GetSiteMapDataSource(); Menu1.DataBind(); } private SiteMapDataSource GetSiteMapDataSource() { ......

Posted On Saturday, September 17, 2005 10:10 PM

Getting the HTML of a Page
You can easily get the html of a particular page by using the WebClient class which lies in the System.Net namespace. In the code below I get the html source of the yahoo.com and saves it in a text file. private void Button1_Click(object sender, System.EventArgs e) { WebClient webClient = new WebClient(); const string strUrl = "http://www.yahoo.com/"; byte[] reqHTML; reqHTML = webClient.DownloadData(strU... UTF8Encoding objUTF8 = new UTF8Encoding(); string pageHTML = objUTF8.GetString(reqHTML); ......

Posted On Friday, September 16, 2005 8:54 PM

Getting the Machine Information
You can get your machine information by using the System.Environment class. static void PrintMachineInformation() { Console.WriteLine("Machine Name" + System.Environment.MachineN... Console.WriteLine("UserName" + System.Environment.UserName); Console.WriteLine("Tick Count" + System.Environment.TickCount); // Check out System.Envirnment class for more properties } powered by IMHO ......

Posted On Thursday, September 15, 2005 11:14 PM

AJAX Cleans My POSTBACKS
Last night I got my dishes wet by using AJAX. Apart from that I used the real AJAX which stands for (Asyncronous JavaScript And XML) makes the server side calls without using POSTBACKS pretty neat right! You can check out my article AJAX IN ACTION in which I explained that how you can refresh the datagrid without doing a POSTBACK. Check it out, happy coding!

Posted On Wednesday, September 14, 2005 2:05 PM

Opening page in the parent window using LinkButton
I was using frames one was 20% and the other was 80% (Rows) and the smaller frame had a linkbutton which was used to log out the user. I implemented the code as private void LinkButton1_Click(object sender, System.EventArgs e) { // Log out the user here // redirect to the login page string path = "http://localhost/Default.a... Response.Redirect(path); } Unfortunately the Default.aspx page always appear in the 20% frame window. And I wanted it to appear as a whole page. You can easily fix this by ......

Posted On Tuesday, September 13, 2005 12:15 PM

Looking for a full time position in Houston
Hi, This is Mohammad Azam. I will be graduating in December 2005 from University of Houston with Bachelors in Computer Science Degree. Apart from my contributions on asp.net forums I am also founder and auther of www.gridviewguy.com. Currently I am looking for a full time position as an Asp.net, C# developer. Please view my resume at www.azamsharp.net. Thanking you, Mohammad Azam

Posted On Tuesday, September 13, 2005 7:17 AM

Set Style Sheet of a Control Dynamically
Sometimes we need to set the style sheet of a particular control dynamically. This can easily be done by traversing down the Page Control Hirarchy. private void Button1_Click(object sender, System.EventArgs e) { // I made 10 Labels controls dynamically and put them inside the Panel control int counter = 0; string style = ddlStyle.SelectedItem.Value; // Go into the Page Control Collection foreach(Control c in Page.Controls) { if(c.HasControls()) { // Go inside the form element foreach(Control c2 in ......

Posted On Saturday, September 10, 2005 3:11 PM

Tracking User login Attempts Using ViewState
There was a question asked on www.asp.net forums that how can we give only 3 tries to user login. A good way is to use Database so that we can log user attempts. But if you want just a quick solution you can always use ViewState. Here is a simple code that checks for the username and if all three attempts fails than print a friendly message. string userName = txtUserName.Text; // check the viewstate if(ViewState["Attempts"] != null) { if( ( (int) (ViewState["Attempts"]) ) != 3 ) { // You should get ......

Posted On Friday, September 9, 2005 6:37 PM

I am a busy beaver
Wheee I have been soo busy lately. This is my last semester and I am out from University for good. My activity in Asp.net forums have been relatively slow and I have'nt written any article for several lately. Currently I am also looking for a full time job which I can start after I graduate in December 2005. There is just too much stuff going on right now. I just hope this semester goes well and I get a good job. I have my fingers crossed and at the same time offering more prayers :)

Posted On Friday, September 9, 2005 1:27 PM

When Session_End is fired??
There is a lot of confusion in developers that when Session_End event is fired. I wrote a small article on this issue. Here is few lines from the article: Session End event is fired only in the In-Proc Session mode at the end of the request in which Session.Abandon() is called OR when the Session time expires. Session End will not be fired when you close the browser. Let's make a small test in the Global.asax file so that we will know that Session.Abandon is being called. Check out the complete article ......

Posted On Monday, September 5, 2005 7:15 PM

Passing Values using Request.Params
You can pass values from one page to another using Request.Params collection which returns collection of Form elements, Cookies, Server Variables and QueryString. Login.aspx page: private void Button1_Click(object sender, System.EventArgs e) { System.Collections.Speciali... myCol = Request.Params; string userName = Request.Params.Get("txtUser... Server.Transfer("SecondPage... } And the SecondPage.aspx which will receive the values looks something like this: private void ......

Posted On Saturday, September 3, 2005 8:55 AM

Doing a PostBack from the Child Window
Sometimes it is very useful to do a postback on the parent window from the child window. As complicated it sounds in reality its very simple. This can be easily achieved by using JavaScript. Take a look at my article.

Posted On Friday, September 2, 2005 6:46 AM

Detecting PopUp Blockers
I was assigned a task at my workplace to write small piece of code that detects PopUp Blockers. This was easily accomplished using JavaScript. You can view the complete article at Detecting PopUp Blockers

Posted On Thursday, September 1, 2005 7:56 PM

Copyright © Mohammad Azam | Powered by: GeeksWithBlogs.net