Tag - C++

How to pass authentication between two ASP.NET applications

If you have two web applications and every application hosted in a separated server, also every web application has login page, so how we can save our credentials once we logged in first web application and if we want to go to the second application without the second application request my authentication again. There are...

How to add windows forms control in WPF

I will describe how we can use windows forms controls in WPF application.I'll assume I have a WPF Application and I want to use DateTimePicker Control, how I can do that in WPF Application? 1- Create WPF Application.2- Add Stackpanel control.3- in Solution Explorer Add Reference for: System.Windows.FormsWindowsFormsIntegration using WindowsControls = System.Windows.Forms; using WindowsIntegration = System.Windows.Forms.Integration; The below method...

Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack ASP.NET

While I was debugging an ASP.NET Application, I wanted to get an object values I got this error message instead: "Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack" This problem occurs when using Response.Redirect or Server.Transfer method, because the Response.End method ends the page execution...

How to select from Datatable in C#.NET

DataTable Object has a Select Method which acts like Where in SQL Server. So if you want to write filter query you write the column name directly without Where and the filter expression you want. I made a simple example that creates a DataTable and fill it with some data and use Select method: DataTable dt...

How to programmatically create iFrame in ASP.NET

Sometimes we may need to create iFrames and use it within GridView or Repeater, and we want to pass some values to it.This example will show you how to create iFrame Programmatically and add it to a PlaceHolder. HtmlGenericControl myFrame = new HtmlGenericControl(); myFrame.TagName = "IFRAME"; myFrame.Attributes["src"] = "MyPagePath"; myFrame.Attributes["id"] = "myFrame1"; myFrame.Attributes["name"] = "myFrame1"; myFrame.Attributes["width"] = "500"; myFrame.Attributes["height"] = "500"; myFrame.Attributes["class"] =...

How to convert SqlDataSource to DataTable and DataView in C#.NET

Sometimes I want to use SqlDataSource  returned data programmatically and here is how you can do this, In this example I will assume that SqlDataSource  ID is SqlDataSource1 which is the default ID: DataSourceSelectArguments args = new DataSourceSelectArguments(); DataView view = SqlDataSource1.Select(args) as DataView; DataTable dt = view.ToTable();

How to check SQL Server database is exists using C#.NET

The following method using sys. schema and views such as sys.databases and sys.tables.As we know that the old style sysobjects and sysdatabases and those catalog views have been deprecated since SQL Server. private static bool CheckDatabaseExists(string connectionString, string databaseName) { string sqlQuery; bool result = false; try { ...

Select DropDownList item after declarative DataBinding

The declarative controls of ASP.NET are really great. However, there are some times, when it may not seem so.Let's say you have a DropDownList which is bound by a DataSource control. Also, you have other pages hitting this page, with querystrings, and based on the item in the querystring, you'd like the to select that...