Category Archives: Microsoft

Code Snippets ASP.Net

Concatenate data fields as binding expression

Concatenate data fields as binding expression:
[html]
<asp:label id="Label1" runat="server"
text='<%# String.Format("{0}, {1}", Eval("ContactLastName"), Eval("ContactFirstName")) %>’>
</asp:label>
[/html]

how to implemented mailto in Hyperlink asp control inside the gridview:
[html]
<asp:HyperLink id="hl1" runat="server"
NavigateUrl='<%# Eval("Email" , "mailto:{0}") %>’
Text='<%# Eval("Email") %>’>
</asp:HyperLink>
[/html]

Code Snippets .Net Fx

Programmatically set the selected menu item in the Menu control

[vb]
Mnu1.Items(1).Selected = True
[/vb]

[vb]
Mnu1.FindItem("Nutrients").Selected = True
[/vb]

[vb]
mnu1.Items(indexToSelect).Selected = True
[/vb]

[vb]
MenuItem mi = this.Menu1.FindItem("Home");
mi.Selected = true;
[/vb]

[vb]
this.Menu1.Items[0].Selected = true;
[/vb]

Code Snippets .Net Fx VB

Get First and last word from sentence

[vb]
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)
[/vb]

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 Fx ASP.Net 2.0

Pass Array via Query String

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

vb sample:
[vb]
Dim arr = Request.QueryString("var").Split(",")
For Each s In arr
Response.Write("<br />var:" & var)
Next
[/vb]

Code Snippets ASP.Net

Measure a function’s performance

Imports System.Diagnostics

[vb]

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

[/vb]

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

[vb]

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

[/vb]

or

[vb]

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

[/vb]

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

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

4. Run

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

5. Run

[ps] isinteg -s servername -fix -test alltests[/ps]

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