Showing posts with label Example Codes. Show all posts
Showing posts with label Example Codes. Show all posts

Daily Tips- Tip #46- How to refresh an asp.net page automatically?

Sunday, January 31, 2010


<meta http-equiv="refresh" content="300">


www.codecollege.NET

Code to hide and show a div tag using javascript onmouseover and onfocus

Monday, January 18, 2010

<html>
<head>
<script language="JavaScript">
function showhide(id, visibility) {
document.getElementById(id).style.display = visibility;
}
</script>
</head>
<body>
<a href='#' onMouseOver="showhide('divContent', 'inline');" onMouseOut="showhide('divContent','none');" onfocus="showhide('divContent','inline')"; onBlur="showhide('divContent','none')";>This program shows and hides a div using javascript.</a>
<div id="divContent">This program shows and hides a div using javascript.</div>
</body>
</html>
<a href="http://www.codecollege.NET">www.codecollege.NET</a>

ASP.NET Webpart basic sample

Tuesday, October 6, 2009

<h4>
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:WebPartManager ID="WebPartManager1" runat="server">
</asp:WebPartManager>
<table>
<tr>
<td>
<asp:WebPartZone ID="MainZone" runat="server" HeaderText="My WebPart Zone">
<ZoneTemplate>
<asp:Label ID="Label1" runat="server" Title="Content">
<h2>Welcome to my Webparts world</h2>
</asp:Label>
</ZoneTemplate>
</asp:WebPartZone>
</td>
</tr>
</table>
</form>
</body>
</html>



</h4>

<a href="http://www.codecollege.NET">www.codecollege.NET</a>

LINQ Basic Sample with arrays


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LINQSamp1
{
class Program
{
static void Main()
{
int[] ages = { 47, 45, 53, 57,44,63,66 };
IEnumerable seniorcitizen =
from n in ages
where n >50
select n;
foreach (var x in seniorcitizen)
Console.Write("Senior Citizen aged:{0}\n", x);
Console.Read();
}
}
}




www.codecollege.NET

Full Functional sample for ASP.NET FileUpload Server Control

Wednesday, August 12, 2009


The following example will save the uploaded file in the root folder of your application.

Default.aspx
============
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:FileUpload ID="fupTest" runat="server" />&nbsp;
<asp:Button ID="btnUpload" runat="server" OnClick="btnUpload_Click" Text="Upload" />
<br />
<asp:Label ID="lblStatus" runat="server"></asp:Label></div>
</form>
</body>
</html>

Default.aspx.cs
============
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.IO;
public partial class _Default : System.Web.UI.Page
{

protected void btnUpload_Click(object sender, EventArgs e)
{
if (fupTest.HasFile )
{
try
{
string strFileName = Path.GetFileName(fupTest.FileName);
fupTest.SaveAs(Server.MapPath("~/") + strFileName);
lblStatus.Text = "File Uploaded Successfully";
}
catch (Exception ex)
{
lblStatus.Text = "Error File could not be uploaded. The Reason for Failure is: " + ex.Message;
}
}

}
}


www.codecollege.NET

ASP.NET FileUpload Server Control Sample 1


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:FileUpload ID="FileUpload1" runat="server" /></div>
</form>
</body>
</html>


www.codecollege.NET

.NET 3.0, Abbreviations and Expansions, Glossary,

LinkWithin

Blog Widget by LinkWithin

Recommended Books