August 15, 2011

C# - LINQ

Linq
View more presentations from samneang

August 10, 2011

Sharing your link on facebook and twitter

- Facebook:
https://www.facebook.com/sharer/sharer.php?u=http://samneang-ngeth.blogspot.com
- Twitter:
http://twitter.com/intent/tweet?url=http://samneang-ngeth.blogspot.com

August 09, 2011

C# - Sending message queue

1st - Add Assembly in Solution explorer -> add reference -> .NET -> select System.Messaging

2nd - Add this namespace into the page

3rd - add window component in control panel and select "Message Queuing"

4th - Create one message queue named "FaultReportQueue" as written in the code bellow in the "Message Queue" of the left Server Explorer inside Visual Studio design.

5th - write code bellow:
Message msg = new message( [Type any string], new ActiveXMessageFormatter());
MessageQueue queue = new MessageQueue(@".\Private$\FaultReportQueue");
queue.Send(msg, "Fault["+ DateTime.Now.ToString() + "]");


6th - To view the message queue:
- You select the name of queue which is just created inside "Server Explorer -> Server -> Message Queues -> Private Queues -> Queue Messages"
- check the BodyStream property on the right hand side of Visual Studio design


Note You can also send xml as the content of the message.

Writing XML within C#


XmlWriterSettings setting = new XmlWriterSettings();
settings.Indent = true;
StringWriter sw = new StringWriter();
XmlWriter w = XmlWriter.Create(sw, settings);

w.WriteStartDocument();
w.WriteStartElement("FaultReport");
w.WriteAttributeString("UserName", UserNameTextBox.Text);
w.WriteAttributeString("UserEmail", EmailTextBox.Text);
w.WriteString(FaultTextBox.Text);
w.WriteEndElement();
w.WriteEndDocument();
w.Close();

August 08, 2011

Config Custom path of Sitemap within C#

Recently, I'm looking around with Sitemap and SitemapDataSource and I can use it well within Treeview, Menu and SiteMapPath navigation except when I move the sitemap file into another nested folder, I need to config it with the steps bellow.
==============================
1st - You need to config the webconfig under the tag <system.web> withing below statement:

<siteMap enabled="true">
<providers>
<add name="MenuProvider"
type="System.Web.XmlSiteMapProvider,
System.Web,
Version=2.0.3600.0,
Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a"
siteMapFile="~/sitemap/Web.sitemap"/>
</providers>
</siteMap>

2nd - Update the SiteMapProvider of your SitemapDataSource:

<asp:SiteMapDataSource ID="SiteMapDataSource1" SiteMapProvider="MenuProvider" runat="server" />


Thank to the source.