August 2006 - Posts

VB.NET

Private Sub MonthCalendar1_DateChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.DateRangeEventArgs) Handles MonthCalendar1.DateChanged

'Display the dates for selected range
Label1.Text = "Dates Selected from :" & (MonthCalendar1.SelectionRange.Start() & " to " & MonthCalendar1.SelectionRange.End)

'To display single selected of date
'MonthCalendar1.MaxSelectionCount = 1

'To display single date use MonthCalendar1.SelectionRange.Start/ MonthCalendarSelectionRange.End
Label2.Text = "Date Selected :" & MonthCalendar1.SelectionRange.Start

End Sub

C#

private void MonthCalendar1_DateChanged(object sender, System.Windows.Forms.DateRangeEventArgs e)
{
//Display the dates for selected range
Label1.Text = "Dates Selected from :" + (MonthCalendar1.SelectionRange.Start() + " to " + MonthCalendar1.SelectionRange.End);

//To display single selected of date
//MonthCalendar1.MaxSelectionCount = 1;

//To display single selected of date use MonthCalendar1.SelectionRange.Start/ MonthCalendarSelectionRange.End
Label2.Text = "Date Selected :" + MonthCalendar1.SelectionRange.Start;
}

Posted by SushilaSB | 8 comment(s)
Filed under:

Join the Windows Community Site!

Please register and share your comments/suggestion.

http://www.merawindows.com

A great effort put together by fellow MVP's: Raghu Boddu, Soumitra Sengupta and M Rajesh

Posted by SushilaSB | 1 comment(s)

We come across situation many a times where we need the name of the folder in which the file resides. Let's say the folder is as "C:\Project1\CSProj1\somename\file1.cs"

We need to get the folder "somename"

We can do this by using the namespace System.IO. Code goes as below

VB.NET

Dim file As FileInfo = New FileInfo("C:\Project1\VBProj1\somename\file1.vb")
Response.Write(file.Directory & "<br>")  'O/P -> C:\Project1\VBProj1\somename
Response.Write(file.Directory.Name)      'O/P -> somename

C#

FileInfo file = new FileInfo(@"C:\Project1\CSProj1\somename\file1.cs");
Response.Write(file.Directory + "<br>");  //O/P -> C:\Project1\CSProj1\somename
Response.Write(file.Directory.Name);     //O/P -> somename

More about FileInfo members

Posted by SushilaSB | 21 comment(s)
Filed under:

VB.NET

Shared Function ExtractNumbers( ByVal expr As String ) As String
 Return String.Join( Nothing, System.Text.RegularExpressions.Regex.Split( expr, "[^\d]" ) )
End Function

C#

static string ExtractNumbers( string expr )
{
 return string.Join( null,System.Text.RegularExpressions.Regex.Split( expr, "[^\\d]" ) );
}

Call the function as follows

VB.NET

Response.Write ( ExtractNumbers( "12EFR77" ) )

C# 

Response.Write ( ExtractNumbers( "12EFR77" ) );

Posted by SushilaSB | 29 comment(s)
Filed under:

To open pop-up window using <asp:dropdownlist..>

VB.NET

Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
 Response.Write("<script>window.open('" + DropDownList1.SelectedValue + "');</script>")
End Sub

C#

protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
Response.Write("<script>window.open('" + DropDownList1.SelectedValue + "');</script>");

To pop-up using client-side event

VB.NET

DropDownListID.Attributes("onchange") = "<open pop up here>"

C#

DropDownListID.Attributes("onchange") = "<open pop up here>";

Posted by SushilaSB | 5 comment(s)
Filed under:
More Posts