We often get hundreds of mails in our Outlook Inbox and want to do some processing with these mails. This scenario arises mainly with the customer support people who wanted to act depending on the mail subject line. Here is a simple code to parse the Microsoft Outlook Inbox:

I have faced this issue a lot of time, where I want to know what control caused the asp.net page to postback. If you study carefully, you will find that ALL the server side asp.net controls are rendered as simple HTML to the client browser. When a postback occurs some event at the server side is triggered such as Button_Click, SelectedIndexChanged, Page_Load etc. Now let's go in some more details.. The rendered asp.net page is nothing but a plain HTML. Now when the page causes a postback, the asp.net engine needs to know what has cused the postback. Depending on this, the engine will trigger particular event on the server side. How does the asp.net engine know what control has caused postback???

If you view the source of the rendered asp.net page you would find some hidden text fields such as __EVENTTARGET, __EVENTARGUMENT, __VIEWSTATE. These fields act as information storage for the HTML page. They convey the postback infromation to the asp.net engine, which can then trigger appropriate event.

When you change the index of dropdown control or any other control, a javascript function name "__doPostBack" is invoked. This function is responsible for saving the control information along with control arguments i.e. called as EventTarget and EventArguments. The __EVENTTARGET field stores the name of the control that caused postback. Hence by simply querying this hidden field we can get the name of the control that caused postback as shown below:

This will work absolutely fine with TextBox, DropDown, LinkButton control, but it won't work with Button control. Since the Button control is rendered as <input type="Submit" />. The __doPostBack function is not called in this case, hence the hidden field __EVENTTARGET is not set. Now in such case how to find the control name that caused postback?

An IMPORTANT point to note is a Submit button i.e. <input type="Submit" /> is not added to the Form until it causes a postback. This means that if their are 3 buttons on the page names B1, B2 and B3. And B2 caused a postback then B1 and B3 will not be added to the form. Thus if the Button causes a postback we can definitely search it in page.Request.Form as shown below:

We get many advance Calendar controls on the internet and in controls library, but I was struggling to find the Month Calendar control. A control that will only display months in a year with a hyperlink(event). Finally here is one that I have developed.

This is a fantastic problem that I faced. I was having a user control in my asp.net application as MSDD.ascx. I wanted to dynamically display this user control from the code written in the Dynamic.cs file in app_code folder of my applicaiton. But at this movement, I was unable to access the MSDD class written in codebehind file from my class in app_code. How can we proceed now???

Solution:

The best solution is to write an Interface. Place this interface in the app_code folder of you application. The aspx codebehind class should implment this particular interface. Now via interface you can access the codebehind class from you class in app_code folder. See the scenario below:

I have following files:

ASPX: A user control/class named MSDD.

app_code: A call named Dynamic, in which I want to access the above user control class MSDD.

Now write an interface IMSDD and make the codebehind class MSDD to implement this IMSDD interface. So you MSDD class will look like:

public

class MSDD : IMSDD

{

// Code here...

}

And your Dynamic class which uses the Interface will look like:

public

classDynamic

{

IMSDDctrl = (IMSDD) Page.LoadControl("../MSDD.ascx");

// Now using this interface you can invoke any method/property of the MSDD class this is exposed via the interface.

Here is a sample code to start the notepad.exe on a remote computer. This code works well with all the Windows operating system except for the advance OS like Windows XP the notepad opens in an invisible mode. In the code below you need to replace "server" with the name of the computer where you want to start the process.

We often feel horrible when we send email messages to our bosses without any subject line. Here is a simple way to avoid such mistakes...

Steps: -1. Open your Outlook,2. Press Alt+F11. This opens the Visual Basic Editor and then Press Ctrl+R which in turn open Project-Project 1 (left side)3. On the Left Pane, one can see "Microsoft Outlook Objects" or "Project1", expand this. Now one can see the "ThisOutLookSession".4. Double click on "ThisOutLookSession". It will open up a Code Pane on the right hand side.5. Copy and Paste the following code in the right pane (Code Pane) and save it

This article will tell you two method of inserting bulk records into a T-SQL table from a DataTable in C#:

1. Bulk insert using the SqlBulkCopy class

2. Bulk insert by passing XML data table to the stored procedure

The first method is used ONLY to insert the data to the database and is simple as compared to the second method. The second method can be used to do some complex processing while inserting/updating the data in the SQL table.

In the first method we will make use of the SqlBulkCopy class provided in .NET. Following code illustrates the use of the SqlBulkCopy class for bulk insert:

About Me

Sandeep Aparajit

Sandeep is a software engineer, working for Microsoft. He loves to hunt challenging problems. He has bagged MCP, MCTS in .NET, C# and ASP.NET. He is also certified in Analyzing Requirements and Defining Microsoft .NET Solution Architectures. Actively involved in forums.microsoft.com, CodeProject.com, C# Corner, ASP.NET, Community-credit.com etc.He has provided several training sessions to freshers and experienced people on C# and .NET.
Apart from his technical portfolio, he loves Photography. He is a spiritual person and believes in god.

Buy Original Microsoft Software

Disclaimer:

All reasonable measures have been taken to ensure the quality, reliability, and accuracy of the information on this website. However, I:

*may delete, add to, or amend information on this website without notice

*am not responsible for the content of other websites linked to, or referenced from, this website and,makes no warranties or representations, expressed or implied, as to the accuracy of information contained at this site.

The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.