Thursday, 11 of March of 2010

News

How to bind data in dropdownlist using generic dictionary collection

Add this reference using System.Collections.Generic.

This is the code in adding custom data in generic dictionary collection
dictionary

Now you can bind the generic dictionary collection to your dropdownlist control
dropdown

This is what it looks like

Full

Happy coding ^_^


How to create a custom error log in C#

This is the easiest way to track your errors in your system. Save the details in a text file, heres how to do it.

Add a public class in your project so that it would be globaly used.

public void ErrLogs(string log, string path)
{
string sLogFormat = DateTime.Now.ToShortDateString().ToString() + ” ” + DateTime.Now.ToLongTimeString().ToString() + ” ==> “;
string spath = path + DateTime.Now.ToShortDateString().ToString() + “.txt”;

FileStream fs = new FileStream(spath, FileMode.OpenOrCreate, FileAccess.ReadWrite);
StreamWriter m_streamWriter = new StreamWriter(fs);
m_streamWriter.BaseStream.Seek(0, SeekOrigin.End);
string value = sLogFormat + log;
m_streamWriter.WriteLine(value);
m_streamWriter.Flush();
m_streamWriter.Close();
}

This is what it looks like in your text file.

10/27/2009 3:35:07 AM ==> CustomerItem.aspx | cmdSave_click Parameter: @levels is missing from stored procedure: gen_IseitzCustomerSelectByIseitzCustomerSinglePk

Happy coding :D


Do your comment

Sample Word Puzzle Generator in ASP.NET/C#

puzzle

This is a sample Puzzle Project created in ASP.NET C#.
With a dynamic word generator.
Input for hidden word.


Download Puzzle here


Do your comment

Web Based Simple Library System

LS Online Library System ASP.Net 3.5

A sample project created for managing books in school libraries.
Created in ASP.NET C#
Subsonic 2.1 Final
MS SQL Server 2005


Download Library System here


Do your comment

How to upload file using C# code

First you have to create FTP request

FtpWebRequest request = (FtpWebRequest)FtpWebRequest.Create(FTPAddress + “/” + Path.GetFileName(filePath));

request.Method = WebRequestMethods.Ftp.UploadFile;
request.Credentials = new NetworkCredential(username, password);
request.UsePassive = false;
request.UseBinary = true;
request.KeepAlive = false;

Then load the file

FileStream stream = File.OpenRead(filePath);
byte[] buffer = new byte[stream.Length];

stream.Read(buffer, 0, buffer.Length);
stream.Close();

Upload the file

Stream reqStream = request.GetRequestStream();
reqStream.Write(buffer, 0, buffer.Length);
reqStream.Close();


1 comment

How to get your ISP IP address in ASP.Net C#

Using the http://www.whatismyip.com website and System.Net.WebClient(), you can get your ISP IP address.

Here’s what it look like in the code:

string ip = new System.Net.WebClient().DownloadString((“http://www.whatismyip.com/automation/n09230945.asp”));
Console.WriteLine(“My IP address is ” + _ip);


Do your comment

How to create popup message box using javascript in ASP.Net C#

Generate a popup message using javascript alert function then dumped it into a label with the string argument passed in to supply the alert box text.

Label lbl = new Label();
lbl.Text =”<script language=”javascript”> window.alert(” + “‘” + msg + “‘” + “)</script>”; 

Then add the label to the page to display the alert

Page.Controls.Add(lbl);

Here’s what it looks like:

private void MessageBox(string msg) {
Label lbl = new Label();
lbl.Text = “<script language=”javascript”> window.alert(” + “‘” + msg + “‘” + “)</script>”;
Page.Controls.Add(lbl);
}


4 comments

How to create Captcha in ASP.NET VB

captchaVB

CaptchaVB.NET
This is originally created in C#, and I converted it to  ASP.NET VB. Enjoy!!!

Download CaptchaVB.NET here


Do your comment

Simple Image Gallery in ASP.NET C#

imageGallery ImageGallery.Net
ImageGallery.Net Features multiple uploads,
image viewer using greybox ajax framework,
Subsonic for DAL(Data Access Layer).

Created in ASP.NET/C# 3.5 Framework


Download ImageGallery.Net here.


Do your comment

How to Create XML in ASP.NET 3.5

This is very easy and sufficient way in building XML data.

Using the System.XML.Linq in .NET 3.5 makes building xml data extremely easy.

Here’s what it looks like in the code:

XElement doc = new XElement("movie",
new XElement("styles",
new XElement("lineStyle",
new XAttribute("id", "lineBlack"),
new XAttribute("color", "#000000"),
new XAttribute("width","1"))
)
);

will give you the following xml:

<movie>
<styles>
<lineStyle id=”lineBlack” color=”#000000″ width=”1″ />
</styles>
</movie>


1 comment