http://support.esri.com/index.cfm?fa=knowledgebase.techarticles.gateway&p=66&pf=1560
Tuesday, December 9, 2008
Monday, December 8, 2008
Animation of Image in C#.net using Ajax
Give the image path to Image Control
Set Animation Extender ->Target Control Id to Image
And Put This code in Source code of the form
Source Code:
Animations
OnClick
FadeOut Duration=".5" Fps="20"
/FadeOut
/OnClick
/Animations
Note:Please keep all the above code in Tag <> Format for all the lines.
Source code for keeping div in scroll bar format
To play a video file in .net and execute it in IExplorer
classid='CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95'
codebase='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701'
standby='Loading Microsoft Windows Media Player components...' type='application/x-oleobject'
param name='fileName' value="Video/restoration[1].wmv"
param name='animationatStart' value='true'
param name='transparentatStart' value='true'
param name='autoStart' value="true"
param name='showControls' value="true"
param name='loop' value="true"
Note: Please keep all the lines in tag format in source code of the web page
To play a video file in .net and in output firefox
pluginspage='http://microsoft.com/windows/mediaplayer/en/download/'
id='EMBED1' name='mediaPlayer'
src="Video/restoration[1].wmv" autostart="true" loop="true"
EMBED
Note : Please keep in tag format in source code of the web page
Friday, December 5, 2008
MS-Word Short Cuts
| CTRL+N | To Create New Document |
| CTRL+O | To Open the New Document |
| CTRL+S | To Save the file |
| F12 | To Save As |
| CTRL+P | To Print |
| CTRL+Z | Undo |
| CTRL+Y | Redo |
| CTRL+x | Cut |
| CTRL+C | Copy |
| CTRL+V | Paste |
| CTRL+Enter | Page Break |
| CTRL+F | Find |
| CTRL+G | Goto |
| CTRL+H | Replace |
| CTRL+K | Hyper Link |
| CTRL+Shift+> | To increase the font with 2pts |
| CTRL+Shift+< | To decrease the font with 2pts |
| CTRL+} | To increase the font with 1pt |
| CTRL+{ | To decrease the font with 1pt |
| CTRL+F2 | To print preview |
| CTRL+ALT+I | To print preview |
| ALT+F8 | To create a macro |
| CTRL+D | To show the Font Dialog |
| CTRL+B | Bold |
| CTRL+I | Italic |
| CTRL+U | Underline |
| CTRL+L | Left Alignment |
| CTRL+E | Center Alignment |
| CTRL+R | Right Alignment |
| CTRL+J | Justify Alignment |
| =rand(100,19) | To create a sample document with 25 pages. |
| CTRL+A | Select All |
| Alt+F4 | To close the application |
| CTRL+Shift+F | To Select the Font |
| CTRL+Shift+S | To select the Style |
| CTRL+Shift+E | To Activate Track Changes |
| CTRL+Shift+P | To Select the Font Particular Size |
URL for DOTNET VIDEOS..............
http://www.dotnetvideos.net/
http://www.asp.net/LEARN/videos/
http://www.fincher.org/tips/Languages/csharp.shtml
http://www.functionx.com/csharp/
http://www.wonderhowto.com/computer-programming/c-sharp-video/
http://www.wonderhowto.com/how-to/video/how-to-create-vb-net-programs-from-the-ground-up-216794/
http://safari.oreilly.com/0596003765
http://safari.oreilly.com/0596003765/learncsharp-CHP-1#X2ludGVybmFsX1RvYz94bWxpZD0wNTk2MDAzNzY1L2xlYXJuY3NoYXJwLUNIUC0xLVNFQ1QtMg==
http://mitchfincher.blogspot.com/
http://in.youtube.com/results?search_query=c%23.net&search_type= (C#.net)
Code for printing message box
Note:Please keep script herer in tag format
Then Enjoy!!!
Code for grid view sorting by clicking on the image button which is kept beside the column name in the same column
in source................
form id="form1" runat="server">
div
asp:Label ID="Label1" runat="server" Font-Bold="True" Font-Size="X-Large" Style="z-index: 100;
left: 187px; position: absolute; top: 30px" Text="Sample Sortable GridView"
asp:Label
asp:GridView ID="gvHours" runat="server" AllowSorting="True" AutoGenerateColumns="False"
CellPadding="4" ForeColor="#333333" GridLines="None" OnRowCreated="gvHours_RowCreated"
OnSorting="gvHours_Sorting" Style="z-index: 102; left: 65px; position: absolute;
top: 84px" Width="513px"
FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White"
RowStyle BackColor="#EFF3FB"
Columns
asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name"
asp:BoundField DataField="Hours" HeaderText="Hours" SortExpression="Hours"
ItemStyle HorizontalAlign="Center"
asp:BoundField
asp:BoundField DataField="Date" DataFormatString="{0:d}" HeaderText="Date" SortExpression="Date"
ItemStyle HorizontalAlign="Center"
asp:BoundField
Columns
PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center"
SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333"
HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White"
EditRowStyle BackColor="#2461BF"
AlternatingRowStyle BackColor="White"
asp:GridView
div
form
Note: Please keep all the above source code in the their respective formats
in code .cs file/////////////////
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
HoursDAL hoursDAL = new HoursDAL();
ArrayList hourList = hoursDAL.GetHours();
ViewState["HourList"] = hourList;
gvHours.DataSource = hourList;
gvHours.DataBind();
}
private int GetSortColumnIndex()
{
// Iterate through the Columns collection to determine the index
// of the column being sorted.
foreach (DataControlField field in gvHours.Columns)
{
if (field.SortExpression == (string)ViewState["SortExpression"])
{
return gvHours.Columns.IndexOf(field);
}
}
return -1;
}
// This is a helper method used to add a sort direction
// image to the header of the column being sorted.
private void AddSortImage(int columnIndex, GridViewRow headerRow)
{
// Create the sorting image based on the sort direction.
Image sortImage = new Image();
if (GridViewSortDirection == SortDirection.Ascending)
{
sortImage.ImageUrl = "~/images/uparrow.gif";
sortImage.AlternateText = "Ascending Order";
}
else
{
sortImage.ImageUrl = "~/images/downarrow.gif";
sortImage.AlternateText = "Descending Order";
}
// Add the image to the appropriate header cell.
headerRow.Cells[columnIndex].Controls.Add(sortImage);
}
private SortDirection GridViewSortDirection
{
get
{
if (ViewState["sortDirection"] == null)
ViewState["sortDirection"] = SortDirection.Ascending;
return (SortDirection)ViewState["sortDirection"];
}
set { ViewState["sortDirection"] = value; }
}
private void SortGridView(string sortExpression, string direction)
{
ArrayList hourList = (ArrayList)ViewState["HourList"];
DataTable dt = new DataTable();
dt.Columns.Add("Name");
dt.Columns.Add("Hours");
dt.Columns["Hours"].DataType = System.Type.GetType("System.Double");
dt.Columns.Add("Date");
dt.Columns["Date"].DataType = System.Type.GetType("System.DateTime");
foreach (HoursBE hours in hourList)
{
DataRow dr = dt.NewRow();
dr["Name"] = hours.Name;
dr["Hours"] = hours.Hours;
dr["Date"] = hours.Date;
dt.Rows.Add(dr);
}
DataView dv = new DataView(dt);
dv.Sort = sortExpression + direction;
gvHours.DataSource = dv;
gvHours.DataBind();
}
private const string ASCENDING = " ASC";
private const string DESCENDING = " DESC";
protected void gvHours_Sorting(object sender, GridViewSortEventArgs e)
{
string sortExpression = e.SortExpression;
ViewState["SortExpression"] = sortExpression;
if (GridViewSortDirection == SortDirection.Ascending)
{
GridViewSortDirection = SortDirection.Descending;
SortGridView(sortExpression, DESCENDING);
}
else
{
GridViewSortDirection = SortDirection.Ascending;
SortGridView(sortExpression, ASCENDING);
}
}
protected void gvHours_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Header)
{
int sortColumnIndex = GetSortColumnIndex();
if (sortColumnIndex != -1)
{
AddSortImage(sortColumnIndex, e.Row);
}
}
}
}
Ajax Moderator pop control
Take ajax enabled script manager, one link button and one panel
-------------------------in source file--------------------------------------
cc1:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="LinkButton1" PopupControlID="Panel1" BackgroundCssClass="modalbackground" DropShadow="true" OkControlID="okbutton" OnOkScript="onOk()" CancelControlID="CancelButton" PopupDragHandleControlID="Panel3">
Note: Please keep above code in tag format
---------------In css file----------
Create any simple code and save tht file with the name modalbackground.css
body
{
background color:red
}
Then execute and enjoy!!!!!!!!!!
Ajax Moderator pop control
Take ajax enabled script manager, one link button and one panel
-------------------------in source file--------------------------------------
cc1:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="LinkButton1" PopupControlID="Panel1" BackgroundCssClass="modalbackground" DropShadow="true" OkControlID="okbutton" OnOkScript="onOk()" CancelControlID="CancelButton" PopupDragHandleControlID="Panel3">
Note: Please keep above code in tag format
---------------In css file----------
Create any simple code and save tht file with the name modalbackground.css
body
{
background color:red
}
Then execute and enjoy!!!!!!!!!!
Wednesday, December 3, 2008
Asp.net Features and Advantages
ASP.NET is a compiled, .NET-based environment; you can code the applications in any .NET compatible language, including Visual Basic .NET, C#, and JScript .NET. Additionally, the entire .NET Framework is available to any ASP.NET application.
ASP.NET has been designed with scalability in mind, with features specifically tailored to improve performance in clustered and multiprocessor environments. With built in Windows authentication and per-application configuration, you can be assured that your applications are secure.
You can use Web Forms or
ASP.Net allows programmers to develop web applications that interface with a database. The advantage of ASP.Net is that it is object-oriented and has many programming tools that allow for faster development and more functionality.
There are 2 aspects of ASP.Net make it fast, compiled code and caching.
Prior to DOT Net Framework, the code was interpreted into machine language when your website visitor views your page. Now, with ASP.Net the code is compiled into machine language before your visitor ever comes to your site.
Caching is the storage of information that will be reused in a memory location for faster access in the future. ASP.Net allows programmers to set up pages or areas of pages that are commonly reused to be cached for a set period of time to improve the performance of web applications. I have used caching in many of my applications with few records, static and frequently used data.
ASP.Net automatically recovers from memory leaks and errors to make sure that your website is always available to your visitors. Programmers can actually write their code in any of the supported .Net languages like VB.Net, C#, and JScript.Net. In the Learning series, we will be using C# since it’s the widely used language across many companies.
An ASP.NET Framework application is deployed to a server simply by copying the necessary files to the server. No server restart is required, even to deploy or replace running compiled code.
Security is one of the major advantage, you can use built in Windows authentication and also you can set the security configuration by application.
Globalization and Localization in C#.net
Take four labels and text boxes
Take global, local Resources file from solution explorer right click add the parameter values to it
Implement this code and enjoy........
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Globalization;
using System.Threading;
using System.Resources;
using System.Reflection;
using System.Drawing;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
//CultureInfo Class GetCultures gives collection of language.
lblWelcome.Text = Resources.Resource.lblWelcome ;
lblWelcome.ForeColor = Color.FromName(Resources.Resource.lblWelcome);
foreach (CultureInfo ci in CultureInfo.GetCultures(CultureTypes.SpecificCultures))
{
//Filling the language collection into drop-downlistbox for user choice.
ddl_SelectLanguage.Items.Add(new ListItem(ci.EnglishName, ci.Name));
}
//Calling the Event when page loads for the first time.
ddl_SelectLanguage_SelectedIndexChanged(sender, e);
}
}
protected void ddl_SelectLanguage_SelectedIndexChanged(object sender, EventArgs e)
{
Thread.CurrentThread.CurrentUICulture = new CultureInfo(ddl_SelectLanguage.SelectedValue);
Thread.CurrentThread.CurrentCulture = new CultureInfo(ddl_SelectLanguage.SelectedValue);
//Applying Localization
ApplyLocalization();
ApplyUILocalization();
}
private void ApplyUILocalization()
{
lblLanguageName.Text = Convert.ToString(this.GetLocalResourceObject("LanguageName"));
lblLongDate.Text = Convert.ToString(this.GetLocalResourceObject("LongDate"));
lblCurrency.Text = Convert.ToString(this.GetLocalResourceObject("Currency"));
lblAmount.Text = Convert.ToString(this.GetLocalResourceObject("amt"));
}
private void ApplyLocalization()
{
//Lets Assume currency and amount to keep example simple.
double dblCurrency = 500.50;
double dblAmount = 9580000.75;
//No extra effort for localization as you see here.
txtLangName.Text = ddl_SelectLanguage.SelectedItem.Text;
txtLongDate.Text = DateTime.Now.ToLongDateString();
txtCurrency.Text = dblCurrency.ToString("c");
txtAmount.Text = dblAmount.ToString("n");
}
}
Code for Generating Random Challan No in C#.net
private int RandomInt(int min, int max)
{
Random random = new Random();
return random.Next(min, max);
}
private string RandomString(int size, bool lowerCase)
{
StringBuilder builder = new StringBuilder();
Random random = new Random();
char ch;
int i;
for (i = 0; i <= size - 1; i++)
{
ch = Convert.ToChar(Convert.ToInt32((26 * random.NextDouble() + 65)));
builder.Append(ch);
}
//i If lowerCase Then
// Return builder.ToString().ToLower()
//End If
return builder.ToString();
}
//RandomString
public string GetRandChlnNo()
{
StringBuilder builder = new StringBuilder();
builder.Append(RandomString(2, true));
builder.Append(RandomInt(1000, 9999));
builder.Append(RandomString(2, false));
return builder.ToString();
}
Session Calling in Crystal Report
Response.Redirect(("Dummy.aspx"?id=" & Session("userid") & "&seldate="&txtDate.txt)
/////////////////////////in Dummy.aspx
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Partial Class DummyReport2
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim a1 As Integer
Dim a2 As Date
a1 = CInt(Request.Params(0))
a2 = Request.Params(1)
Dim a As String
a = Server.MapPath("DummyReport2.rpt")
Dim cryRpt As New ReportDocument
cryRpt.Load(a)
Dim crParameterFieldDefinitions As ParameterFieldDefinitions
Dim crParameterFieldDefinition As ParameterFieldDefinition
Dim crParameterValues As New ParameterValues
Dim crParameterDiscreteValue As New ParameterDiscreteValue
crParameterValues.Clear()
crParameterDiscreteValue.Value = a1
crParameterFieldDefinitions = cryRpt.DataDefinition.ParameterFields
crParameterFieldDefinition = crParameterFieldDefinitions.Item("SHID")
crParameterValues = crParameterFieldDefinition.CurrentValues
crParameterValues.Add(crParameterDiscreteValue)
crParameterFieldDefinition.ApplyCurrentValues(crParameterValues)
crParameterDiscreteValue.Value = a2
crParameterFieldDefinitions = cryRpt.DataDefinition.ParameterFields
crParameterFieldDefinition = crParameterFieldDefinitions.Item("SelDate")
crParameterValues = crParameterFieldDefinition.CurrentValues
crParameterValues.Add(crParameterDiscreteValue)
'crParameterValues.Add(crParameterDiscreteValue)
crParameterFieldDefinition.ApplyCurrentValues(crParameterValues)
CrystalReportViewer1.ReportSource = cryRpt
End Sub
End Class
Retrieving Any Web Site From C#.net Application
Imports System.IO
Imports System.Net
Imports System.Text
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
' This tutorial is provided in part by Server Intellect Web Hosting Solutions http://www.serverintellect.com
' Visit http://www.AspNetTutorials.com for more ASP.NET Tutorials
Dim req As WebRequest = WebRequest.Create("http://www.eenadu.net")
Dim resp As WebResponse = req.GetResponse()
Dim s As Stream = resp.GetResponseStream()
Dim sr As StreamReader = New StreamReader(s, Encoding.ASCII)
Dim doc As String = sr.ReadToEnd()
lblStatus.Text = doc
End Sub
End Class
Code for check box check or uncheck in Grid View Using C#.net
var TotalChkBx;
var Counter;
window.onload = function()
{
//Get total no. of CheckBoxes in side the GridView.
TotalChkBx = parseInt('<%= this.gvCheckboxes.Rows.Count %>');
//Get total no. of checked CheckBoxes in side the GridView.
Counter = 0;
}
function HeaderClick(CheckBox)
{
//Get target base & child control.
var TargetBaseControl = document.getElementById('<%= this.gvCheckboxes.ClientID %>');
var TargetChildControl = "chkBxSelect";
//Get all the control of the type INPUT in the base control.
var Inputs = TargetBaseControl.getElementsByTagName("input");
//Checked/Unchecked all the checkBoxes in side the GridView.
for(var n = 0; n < Inputs.length; ++n)
if(Inputs[n].type == 'checkbox' && Inputs[n].id.indexOf(TargetChildControl,0) >= 0)
Inputs[n].checked = CheckBox.checked;
//Reset Counter
Counter = CheckBox.checked ? TotalChkBx : 0;
}
function ChildClick(CheckBox, HCheckBox)
{
//get target base & child control.
var HeaderCheckBox = document.getElementById(HCheckBox);
//Modifiy Counter;
if(CheckBox.checked && Counter <> 0)
Counter--;
//Change state of the header CheckBox.
if(Counter < TotalChkBx)
HeaderCheckBox.checked = false;
else if(Counter == TotalChkBx)
HeaderCheckBox.checked = true;
Add onclick attribute for HeaderCheckbox like this:
In asp:CheckBox tag, add this: onclick="javascript:HeaderClick(this);"
Now add the following code in row_created event of GridView
if (e.Row.RowType == DataControlRowType.DataRow && (e.Row.RowState == DataControlRowState.Normal || e.Row.RowState == DataControlRowState.Alternate))
{
CheckBox chkBxSelect = (CheckBox)e.Row.Cells[1].FindControl("chkBxSelect");
CheckBox chkBxHeader = (CheckBox)this.gvCheckboxes.HeaderRow.FindControl("chkBxHeader");
chkBxSelect.Attributes["onclick"] = string.Format("ChildClick(this,'{0}');", chkBxHeader.ClientID);
}
Thats it!!!!!!!!!!
Code for Login Page
----take two txt boxes and one button------------
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;
public partial class Login : System.Web.UI.Page
{
OleDbConnection con = new OleDbConnection(ConfigurationManager.ConnectionStrings["access"].ToString());
OleDbCommand cmd;
protected void Page_Load(object sender, EventArgs e)
{
Page.Form.DefaultFocus = txt_UserName.ClientID;
}
protected void Btn_Login_Click(object sender, EventArgs e)
{
if (ValidateUser(txt_UserName.Text.ToString(), txt_Pwd.Text.ToString()))
{
switch (txt_UserName.Text.ToLower())
{
case "admg":
Response.Redirect("~/Modified/ADMG.aspx");
break;
case "collector":
Response.Redirect("~/Modified/Collector.aspx");
break;
case "ddmg":
Response.Redirect("~/Modified/DDMG.aspx");
break;
case "dfo":
Response.Redirect("~/Modified/DFO.aspx");
break;
case "dmg":
Response.Redirect("~/Modified/DMG.aspx");
break;
case "goi":
Response.Redirect("~/Modified/GOI.aspx");
break;
case "jonaljd":
Response.Redirect("~/Modified/JonalJD.aspx");
break;
case "mro":
Response.Redirect("~/Modified/MRO.aspx");
break;
case "new":
Response.Redirect("~/Modified/application form.aspx");
break;
}
}
Response.Write("Invalid Credentials");
}
private bool ValidateUser(string userName, string passWord)
{
string lookupPassword = null;
// Check for invalid userName.
// userName must not be null and must be between 1 and 15 characters.
try
{
// Consult with your SQL Server administrator for an appropriate connection
// string to use to connect to your local SQL Server.
con.Open();
// Create SqlCommand to select pwd field from users table given supplied userName.
cmd = new OleDbCommand("Select password from Login where Login_name=@userName", con);
cmd.Parameters.AddWithValue("@userName", txt_UserName.Text.ToString());
// Execute command and fetch pwd field into lookupPassword string.
lookupPassword = (string)cmd.ExecuteScalar();
// Cleanup command and connection objects.
cmd.Dispose();
con.Dispose();
}
catch (Exception ex)
{
// Add error handling here for debugging.
// This error message should not be sent back to the caller.
System.Diagnostics.Trace.WriteLine("[ValidateUser] Exception " + ex.Message);
}
// If no password found, return false.
if (null == lookupPassword)
{
// You could write failed login attempts here to event log for additional security.
return false;
}
// Compare lookupPassword and input passWord, using a case-sensitive comparison.
return (0 == string.Compare(lookupPassword, txt_Pwd.Text.ToString(), false));
}
}
Code for Dowload Manager in C#.net
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.IO;
using System.Threading;
namespace DownloadManager
{
public partial class Form1 : Form
{
// The thread inside which the download happens
private Thread thrDownload;
// The stream of data retrieved from the web server
private Stream strResponse;
// The stream of data that we write to the harddrive
private Stream strLocal;
// The request to the web server for file information
private HttpWebRequest webRequest;
// The response from the web server containing information about the file
private HttpWebResponse webResponse;
// The progress of the download in percentage
private static int PercentProgress;
// The delegate which we will call from the thread to update the form
private delegate void UpdateProgessCallback(Int64 BytesRead, Int64 TotalBytes);
public Form1()
{
InitializeComponent();
}
private void btnDownload_Click(object sender, EventArgs e)
{
// Let the user know we are connecting to the server
lblProgress.Text = "Download Starting";
// Create a new thread that calls the Download() method
thrDownload = new Thread(Download);
// Start the thread, and thus call Download()
thrDownload.Start();
}
private void UpdateProgress(Int64 BytesRead, Int64 TotalBytes)
{
// Calculate the download progress in percentages
PercentProgress = Convert.ToInt32((BytesRead * 100) / TotalBytes);
// Make progress on the progress bar
prgDownload.Value = PercentProgress;
// Display the current progress on the form
lblProgress.Text = "Downloaded " + BytesRead + " out of " + TotalBytes + " (" + PercentProgress + "%)";
}
private void Download()
{
using (WebClient wcDownload = new WebClient())
{
try
{
// Create a request to the file we are downloading
webRequest = (HttpWebRequest)WebRequest.Create(txtUrl.Text);
// Set default authentication for retrieving the file
webRequest.Credentials = CredentialCache.DefaultCredentials;
// Retrieve the response from the server
webResponse = (HttpWebResponse)webRequest.GetResponse();
// Ask the server for the file size and store it
Int64 fileSize = webResponse.ContentLength;
// Open the URL for download
strResponse = wcDownload.OpenRead(txtUrl.Text);
// Create a new file stream where we will be saving the data (local drive)
strLocal = new FileStream(txtPath.Text, FileMode.Create, FileAccess.Write, FileShare.None);
// It will store the current number of bytes we retrieved from the server
int bytesSize = 0;
// A buffer for storing and writing the data retrieved from the server
byte[] downBuffer = new byte[2048];
// Loop through the buffer until the buffer is empty
while ((bytesSize = strResponse.Read(downBuffer, 0, downBuffer.Length)) > 0)
{
// Write the data from the buffer to the local hard drive
strLocal.Write(downBuffer, 0, bytesSize);
// Invoke the method that updates the form's label and progress bar
this.Invoke(new UpdateProgessCallback(this.UpdateProgress), new object[] { strLocal.Length, fileSize });
}
}
finally
{
// When the above code has ended, close the streams
strResponse.Close();
strLocal.Close();
}
}
}
private void btnStop_Click(object sender, EventArgs e)
{
// Close the web response and the streams
webResponse.Close();
strResponse.Close();
strLocal.Close();
// Abort the thread that's downloading
thrDownload.Abort();
// Set the progress bar back to 0 and the label
prgDownload.Value = 0;
lblProgress.Text = "Download Stopped";
}
}
}
Code for Printing Message Box in C#.net
-------------web.config------------
script language="javascript" type="text/javascript"
function done()
{
alert("Form Submitted Successfully");
}
/script
Note:Please keep in tag format script line
--------------code editor--------------
ClientScript.RegisterStartupScript(this.GetType(), "msg", "");
Code for Sending Mail to Gmail using C#.net
system.net
mailsettings
smtp from="your_gmail_email@gmail.com"
network host="smtp.gmail.com" password="your_gmail_password" port="587" username="your_gmail_email@gmail.com"
network
smtp
mailsettings
Note: Please keep all the above code in tags format
//pageload
using System.Net.Mail;
using System.Net;
SmtpClient mailClient = new SmtpClient("smtp.gmail.com", "587");
mailClient.EnableSsl = true;
NetworkCredential cred = new NetworkCredential("your_gmail_username","your_gmail_password");
mailClient.Credentials = cred;
mailClient.Send("from_me@gmail.com", "to_you@gmail.com","subject goes here", "email body goes here");
Note: Mail Codes for Other Email-Accounts
yahoo ---> smtp.mail.yahoo.com (port 25)
//gmail ---> smtp.gmail.com (SSL enabled, port 465)
//AOL ---> smtp.aol.com
//Netscape ---> smtp.isp.netscape.com (port 25)
Uninstallation Steps for Oracle 9i
These notes apply to Oracle 9i
The simplest way to remove Oracle is to run the Oracle installer:
Start > Programs > Oracle Installation Products > Universal Installer
1. On the first screen click on "Deinstall Products..."
2. Expand the tree view (just so that the second level is visible) and make sure you select everything that is selectable.
3. Click on "Remove..."
4. On the confirmation screen click "Yes"
5. When it has finished click "Close" and then "Exit" to quit the installer
Whilst the Oracle installer removes many components there are a number of things that it leaves behind. In order to completely remove all traces of Oracle the following additional steps will need to be taken:
1. Stop any Oracle services that have been left running. (Start > Settings > Control Panel > Services.)
Services which I have found left behind are 'OracleOraHome90TNSListener' and 'OracleServiceORACLE'. However there may be others depending on your installation. Look for any services with names starting with 'Oracle'.
2. Run regedit (Start > Run > Enter "regedit", click "Ok"), find and delete the following keys:
HKEY_LOCAL_MACHINE
\SOFTWARE
\ORACLE
HKEY_LOCAL_MACHINE
\SYSTEM
\CurrentControlSet
\Services
\EventLog
\Application
\Oracle.oracle
Note: I have had it reported that some people also have registry entries saved under HKEY_CURRENT_USER\SOFTWARE\ORACLE, this registry entry may be created by some Oracle utilities. If it exists then delete it.
3. Delete the Oracle home directory:
"C:\Oracle"
This will also remove your database files (unless you located them elsewhere, in which case you will need to delete them separately).
4. Delete the Oracle program Files directory:
"C:\Program Files\Oracle"
5. Delete the Oracle programs profile directory:
"C:\Documents and Settings\All Users\Start Menu\Programs\Oracle - OraHome90"
if you did not first run the Oracle installer to remove Oracle then there may be other Oracle profile group directories to remove.
6. Some of the Oracle services may be left behind by the uninstall. Open ‘services’ on the control panel, make a note of which Oracle services remain and see the notes ‘How to remove a service’ to remove them.
7. If you didn't first run the Oracle Installer to remove Oracle then you may have some references to Oracle left in the path. To remove these: Start > Settings > Control Panel > System > Advanced > Environment Variables, look at both the use and system variable 'PATH' and edit them to remove any references to Oracle.
Acknowledgements: My appreciation to Alistair Jones for help on this procedure and for encouragement to write it.
These notes have been tested with Oracle 9i under Windows XP.
Access Masterpage control from Content Page
Example: Suppose a label with id 'Label1' is in the master page.Then a reference to this control can be used in any content page.Now.I am trying to write down the text value of that label in content page like this:
Label mylabel=(Label)Master.FindControl("Label1");
Response.Write(mylabel.text);
About CAPTCHA
It is nothing but -Completely Automated Public Turing test to tell Computers and Humans Apart
Web sites are increasingly under spam attack from automated scripts. “CAPTCHAs” help Web sites to distinguish between human and machine users by forming a problem that is easy for humans to solve, but difficult for machines to solve.
CAPTCHA can control many automated spam attacks against Web sites, but without careful planning, it can also cause problems.
Because CAPTCHAs rely on perception, users unable to perceive a CAPTCHA (for example, due to a disability or because it is difficult to read) will be unable to perform the task protected by a CAPTCHA.
How to find visitors online using asp.net
Ya.Try this-
Just paste the follwing code in global.asax file:
void Application_Start(object Sender, EventArgs E)
{
// Set our user count to 0 when we start the server
Application["ActiveUsers"] = 0;
}
void Session_Start(object Sender, EventArgs E)
{
Session["Start"] = DateTime.Now;
Session.Timeout = 1;
Application.Lock();
Application["ActiveUsers"] = (int)Application["ActiveUsers"] + 1;
Application.UnLock();
}
void Session_End(object Sender, EventArgs E)
{
Application.Lock();
Application["ActiveUsers"] = (int)Application["ActiveUsers"] - 1;
Application.UnLock();
Session.Clear();
Session.Remove("Start");
}
And get the Application["ActiveUsers"] where ever you need it!!!
Ex:label1.text=Application["ActiveUsers"].ToString();
Installing font in to machine using .net
First everyone tries to copy the file to the "C:\Windows\Fonts"(assuming OS is installed on C drive).And gets a flower kept in the ears.Ya.Actually, An application can use a font to draw text only if that font is either resident on a specified device or installed in the system font table.
The font table is an internal array that identifies all nondevice fonts that are available to an application.A method exists to access this table.
Now let us see the code:
using System;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.IO;
using System.Runtime.InteropServices;
public partial class Class_Name : System.Web.UI.Page
{
[DllImport("gdi32")]
public static extern int AddFontResource(string lpFileName);
protected void Page_Load(object sender, EventArgs e)
{
File.Copy(Server.MapPath("mfdev010.ttf"), "C:\\Windows\\fonts\\mfdev010.ttf");
// Adding the font ..
AddFontResource("mfdev010.ttf");
Response.Write("Installation successful");
}
}
Explanation:
Here what i have done is
1.Put the font file in the application directory.
2.First copy the font file to the windows(font location).Be careful to check.some machines may have OS installed in other drives other than C drive.
3.Add the font to the font resource file by using the "AddFontResource" method.However,in order to use this function,you need to write an api(as shown above) using gdi32 dll.
Now as you start debugging,as page loads font gets installed.
Have nice coding!!!
Bye.
How to find visitors online using asp.net
Ya.Try this-
Just paste the follwing code in global.asax file:
void Application_Start(object Sender, EventArgs E)
{
// Set our user count to 0 when we start the server
Application["ActiveUsers"] = 0;
}
void Session_Start(object Sender, EventArgs E)
{
Session["Start"] = DateTime.Now;
Session.Timeout = 1;
Application.Lock();
Application["ActiveUsers"] = (int)Application["ActiveUsers"] + 1;
Application.UnLock();
}
void Session_End(object Sender, EventArgs E)
{
Application.Lock();
Application["ActiveUsers"] = (int)Application["ActiveUsers"] - 1;
Application.UnLock();
Session.Clear();
Session.Remove("Start");
}
And get the Application["ActiveUsers"] where ever you need it!!!
Ex:label1.text=Application["ActiveUsers"].ToString();