Category Archives: Microsoft

Code Snippets .NET

Programmatically set the selected menu item in the Menu control

Mnu1.Items(1).Selected = True
Mnu1.FindItem("Nutrients").Selected = True
mnu1.Items(indexToSelect).Selected = True
MenuItem mi = this.Menu1.FindItem("Home");
 mi.Selected = true;
this.Menu1.Items[0].Selected = true;
Code Snippets .NET VB

Get First and last word from sentence

        Dim Nome As String = "Carlos Galhano"
        Dim firstword As String = Nome.Substring(0, Nome.IndexOf(" "))
        Dim lastWord As String = Nome.Substring(Nome.LastIndexOf(" "c) + 1)
        Response.Write("first: " & firstword & " Last: " & lastWord)
Exchange Microsoft

Enable auth login on smtp server exchange 2010

2 errors can happen:

a) “504 5.7.4 Unrecognized authentication type”
And, after was resolved, (b) happened:
b) “550 5.7.1 Client does not have permission to send as this sender”

read more »

ASP.Net

Using “Cache” in ASP.Net

 Data can be stored on the client – using the view state of the page, or on the server in a variable session state or application, or using the server cache.
ASP.NET implements System.Web.Caching.Cache class to store objects that require a large amount of server resources to be created, so that they do not have to be recreated each time it is needed.
You can access via code information about a class instance cache through the property cache, the object of the HttpContext or Page object.
Expiration policy for items in cache:
  • Specific time:  absolute expiration
  • May also expire if not accessed for a period of time:  sliding expiration

read more »

Code Snippets .NET ASP.Net 2.0

Pass Array via Query String

http://galhano.com/?var=1&var=2&var=3&var=4

vb sample:

  Dim arr = Request.QueryString("var").Split(",")
  For Each s In arr
    Response.Write("<br />var:" & var)
  Next
Code Snippets ASP.Net

Measure a function’s performance

Imports System.Diagnostics


Dim sw As New Stopwatch()
sw.Start()
' Do the work here
sw.Stop()
Console.WriteLine("Elapsed time: {0}", sw.Elapsed.TotalMilliseconds)

IIS Microsoft

IIS 8.0 error 401.2

Goto  IIS Console > web site properties >IIS authentication and Activate “Basic Authentication”

Code Snippets ASP.Net ASP.Net 2.0

Add value for dropdown list in asp.net


ListItem li =new ListItem();
 li.value="PT";
 li.Text="Portugal";
 dropdownlist1.Items.Add(li);

or


dropCategory.Items.Add( New ListItem( "Portugal", "PT" ) )

Exchange Microsoft

Fix corrupted Public Folder in exchange 2003

Fix corrupted Public Folder in exchange 2003:

1. Dismount the store
2. From a command prompt, navigate to z:\program files\exchsrvr\bin folder where z: represents the drive where the exchange program files were installed.
3. Run

eseutil /p "z:\program files\exchsrvr\mdbdata\pub1.edb" 

4. Run

eseutil /d "z:\program files\exchsrvr\mdbdata\pub1.edb"

5. Run

 isinteg -s servername -fix -test alltests

(choose the Public Folders when prompted)
6. Run the above command again to make sure isinteg has fixed all errors (last line should read 0 errors and 0 fixes).
7. Re-mount the Public Folder store.

All should be repaired now.

Code Snippets .NET ASP.Net

Set Calendar Extender’s SelectedDate=”<%=DateTime%>”

&lt;asp:TextBox ID=&quot;txtDate&quot; runat=&quot;server&quot; &gt;&lt;/asp:TextBox&gt;
&lt;cc1:CalendarExtender ID=&quot;CalendarExtender1&quot; runat=&quot;server&quot; TargetControlID=&quot;txtDate&quot; Format=&quot;MM/dd/yyyy&quot; OnClientShowing=&quot;showDate&quot; &gt; &lt;/cc1:CalendarExtender&gt;
&lt;script type=&quot;text/javascript&quot; language=&quot;javascript&quot;&gt;
function showDate(sender,args)
{
if(sender._textbox.get_element().value == &quot;&quot;)
{
var todayDate = new Date();
sender._selectedDate = todayDate;
}
}
&lt;/script&gt;