History   |   Planning   |   HTML/CSS   |   JavaScript   |   ASP   |   .Net 1.0   |   .Net 2.0   |   .Net 3.0   |   C#   |   Java   |   SQL   |   XML   |   GIS   |   Software   |   Glossary
.Net 1.0
    - Alert

    - Basic

    - Config

    - Console App

    - Convert

    - DTS

    - Event Log

    - Filestream

    - GAC

    - Index Of

    - Pop3

    - Set Focus

    - Starts With

    - Windows Service

 
C# : Alert
.Net 1
<script language="C#" runat="server">
 protected  void Page_Load(object sender, EventArgs e){
   //Set the button's client-side onmouseover event
   btnClick.Attributes.Add("onClick", "alert('You clicked me!');");
 }
</script>

<form runat="server" ID="Form2">
 <asp:button runat="server" Text="Click Me!" id="btnClick" />
</form>
.Net 2
<asp:Button ID=button1 runat=server
OnClientClick="return('Are you sure you want to delete this record')"
Text="Delete Record" />
Jump to Top
C# : Basic
User.cs Class
using System;

namespace WAB.Conexis
{
	/// <summary>
	/// Summary description for User.
	/// </summary>
	public class User
	{
		public User()
		{
			//
			// TODO: Add constructor logic here
			//
		}
		public int Login(string username, string password)
		{
			if (username == "charles" && password == "111111")
			{
				return 1;
			}
			else
			{
				return 0;
			}
		}
	}
}
WebForm1.aspx.cs
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using WAB.Conexis;

namespace CSharpTest
{
	/// <summary>
	/// Summary description for WebForm1.
	/// </summary>
	public class WebForm1 : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.Label lblMessage;

		private void Page_Load(object sender, System.EventArgs e)
		{
			// Put user code to initialize the page here
			User user = new User();
			int ret = user.Login("charles", "111111");
			lblMessage.Text = Convert.ToString(ret);
		}

		#region Web Form Designer generated code
	}
}
Jump to Top
C# : Config
app.config
<?xml version="1.0" encoding="Windows-1252"?>
<configuration>
	<appSettings>
		<add key="serverName" value="myServer" />
		<add key="userName" value="sa" />
		<add key="password" value="password" />
		<add key="packageName" value="TestDTS" />
		<add key="interval" value="30000" />
	</appSettings>
</configuration>
file
using System.Configuration;
string serverName = ConfigurationSettings.AppSettings["serverName"];
Jump to Top
C# : Console App
string x = "yyy ntp est";

if (x.IndexOf("np") != -1)
{
	Console.WriteLine("valid");
	Console.ReadLine();
}
else
{
	Console.WriteLine("in-valid");
	Console.ReadLine();
}
Jump to Top
C# : Convert
timer.Interval = Convert.ToDouble(ConfigurationSettings.AppSettings["interval"]);

Convert.ToDateTime(txtDepartDate.Text);
Jump to Top
C# : DTS
Click here

Runtime Callable Wrapper (RCW):
1) Strong Name Tool: create key sn.exe -K c:\dts.snk
(c:\program files\microsoft visual studio .net\sdk\v1.1\bin)
2) Create RCW assembly: Click here
3) Install RCW in GAC: Click here
Jump to Top
C# : Event Log
using System.Diagnostics;

EventLog.WriteEntry("POPService", x.Message);
Jump to Top
C# : Filestream
private void AddToFile(string contents)
{
	FileStream objFileStream = new 
	FileStream(@"c:\pop3grabber.txt", FileMode.OpenOrCreate, FileAccess.Write);
	
	StreamWriter objStreamWriter = new StreamWriter(objFileStream);

	objStreamWriter.BaseStream.Seek(0, SeekOrigin.End);

	objStreamWriter.WriteLine(contents);

	objStreamWriter.Flush();

	objStreamWriter.Close();			
}
Jump to Top
C# : GAC
Path
C:\WINDOWS\assembly
Jump to Top
C# : IndexOf
string x = "yyy npz est";

if (x.IndexOf("np") != -1)
{
	Console.WriteLine("valid");
	Console.ReadLine();
}
else
{
	Console.WriteLine("not valid");
	Console.ReadLine();
}
Jump to Top
C# : Pop3
Click here
Jump to Top
C# : Set Focus
.Net 1
private void SetFocus(String ctrlID)
{
 // Build the JavaScript String
 System.Text.StringBuilder sb = new System.Text.StringBuilder();
 sb.Append("")

 // Register the script code with the page.
 Page.RegisterStartupScript("FocusScript", sb.ToString());
}
.Net 2
void Page_Init(object sender, EventArgs e)
{
 SetFocus(ControlToSetFocus);
}

// OR (call in Page_Load)
TextBox1.Focus();
Jump to Top
C# : Starts With
private string VerifyMessage(string subject)
{
	if (subject.ToLower().StartsWith("np"))
	{
		return "NPTest.txt";
	}
	else if (subject.ToLower().StartsWith("sonoma"))
	{
		return "sonoma.txt";
	}
	else
	{
		return "";			
	}
}
Jump to Top
C# : Windows Service
Click here

Install: C:\> cd windows\microsoft.net\framework\v1.1.4322

C:\windows\microsoft.net\framework\v1.1.4322> installutil c:\services\MyService.exe

Remove: C:\windows\microsoft.net\framework\v1.1.4322> installutil /u c:\services\MyService.exe
Jump to Top
 
Copyright © 2010 12 Bravo