Archive | ASP.NET RSS feed for this section with Gmail account

14 May


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
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.

.NET developer Blog with examples

17 Mar


Variables inside SqlDataSource.SelectCommand

26 Feb

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


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


End Sub

SqlDataSource1.SelectCommand = sqlString

Detecting a Client’s screen resolution in ASP.NET

23 Feb


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
} 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();
// JavaScript code below will determine the user screen resolution
// and redirect to itself with action=set QueryString parameter

<script language=”javascript”>
res = “&res=”+screen.width+”x”+screen.height+”&d=”+screen.colorDepth

Keeping ASP.NET Session Alive

22 Feb