Archive | ASP.NET RSS feed for this section

System.net.mail with Gmail account

14 May

http://geekswithblogs.net/aymanfm/archive/2006/03/09/71868.aspx

Dropdownlist style in ASP.NET

13 May

Sub Page_Load(ByVal Src As Object, ByVal E As EventArgs)
Dim MyStyle As New Style
MyStyle.BackColor = Drawing.Color.Aqua
DropDownList1.ApplyStyle(MyStyle)
End Sub

ASP.NET Color references

13 May

Some Controls in ASP.NET you need to set style with color names established this reference give you an idea of how it looks.  It’s better than looking and looking until you find the right one to use.

http://www.opinionatedgeek.com/DotNet/Tools/Colors/default.aspx

.NET developer Blog with examples

17 Mar

Ref:http://mattberseth.com/blog/aspnet/

Variables inside SqlDataSource.SelectCommand

26 Feb

This way of working with sqlDatasource is very versatile a let you create a lot of handy stuff.

Ref:http://www.maconstateit.net/tutorials/aspnet20/ASPNET13/aspnet13-03.aspx

My Example:

I need to let the users select from two calendars control the ranges of dates they want to get from database.

Protected Sub Calendar1_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Calendar1.SelectionChanged
Dim begin_date As String = “”
begin_date = Calendar1.SelectedDate.ToString
TextBox3.Text = begin_date
End Sub

Protected Sub Calendar2_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Calendar2.SelectionChanged
Dim end_date As String = “”
end_date = Calendar2.SelectedDate.ToString
TextBox4.Text = end_date
End Sub

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim sqlString As String = “Select [id],[x],[y], [cat_name], [zone_id], [name], [addr], [town], [phone], [webpage], [description], [town], [image_1], [fecha] From [ptg_events] where fecha between ‘” & TextBox3.Text & “‘ and ‘” & TextBox4.Text & “‘”
SqlDataSource1.SelectCommand = sqlString
SqlDataSource1.SelectCommandType = SqlDataSourceCommandType.Text

GridView1.DataBind()

End Sub

SqlDataSource1.SelectCommand = sqlString

Detecting a Client’s screen resolution in ASP.NET

23 Feb

Ref:http://devcity.net/Articles/64/1/screenresolution.aspx

Default.aspx Code:

public void Page_Load(Object sender, EventArgs e){

if (Session[“ScreenResolution”] == null) {
// Session variable is not set
// Redirect to the screen resolution detection script
Response.Redirect(“detectscreen.aspx”);
} else {
// Session variable is set
// Display it on the page
screenresolution.Text = Session[“ScreenResolution”].ToString();
}
}

detectScreen.aspx Code:

<script runat=”server” language=”C#”>

public void Page_Load(Object sender, EventArgs e){

if (Request.QueryString[“action”] != null) {
// store the screen resolution in Session[“ScreenResolution”]
// and redirect back to default.aspx
Session[“ScreenResolution”] = Request.QueryString[“res”].ToString();
Response.Redirect(“cat.aspx”);
}
}
// JavaScript code below will determine the user screen resolution
// and redirect to itself with action=set QueryString parameter

</script>
<script language=”javascript”>
res = “&res=”+screen.width+”x”+screen.height+”&d=”+screen.colorDepth
top.location.href=”detectscreen.aspx?action=set”+res
</script>

Keeping ASP.NET Session Alive

22 Feb

Ref:http://www.codeproject.com/KB/session/Session_Defibrillator.aspx