Some day I will know everything. I hope that day never comes.
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 ......
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); } ......
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 ......
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 ......
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 ......
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 ......
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 ......
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 ......
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... ......
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 ......
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() { ......
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); ......
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 ......
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!
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 ......
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
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 ......
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 ......
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 :)
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 ......
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 ......
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.
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