Saturday, 6 April 2013

Browser in Visual Studio LightSwitch

How to use the browser in Microsoft visual studio lightswitch?

Overview of Article

Continuing with our earlier post on adding custom controls from the System.Windows.Controls namespace, the following article describes how to add a WebBrowser control onto a LightSwitch Screen.
This will allow us to display HTML or load web pages onto a LightSwitch Screen.

Screens

This example is not based upon any data. Therefore, create a new screen using the ‘New Data Screen’ template and select ‘Screen Data (None)’.


1. In order for us to add a WebBrowser control onto the screen, we need to bind the control it to a notional piece of data. Therefore, click the ‘Add Data Item’ button and add a new local property of type string. Untick the ‘Is Required’ checkbox and name the control ‘htmlpage’.


2.Drag the control onto the screen. Change the control from a TextBox into a Custom Control. On the properties pane, click the ‘change’ hyperlink and select ‘System.Windows.Controls.WebBrowser’.


Now click on WriteCode button in the right topmost corner. Do some coding under display's Activated function.

partial void Webpage_Activated()
  {
     this.FindControl("htmlpage").ControlAvailable += webControlAvailable;
  }

private void webControlAvailable(object sender, ControlAvailableEventArgs e)
   {
     ((System.Windows.Controls.WebBrowser)e.Control).Navigate(new Uri(http://gmail.com"));
   }

Now hit F5 and execute this .The Resulting window will be like this.



Thursday, 4 April 2013

Important Sql Queries

Q 1: How to get columns of a table in Sql Server?

Ans :  There are many ways to do this
  1. EXEC sp_columns 'tbFeeStructure',null,null,null,0
  2. SELECT * FROM sys.columns WHERE object_id = OBJECT_ID('dbo.yourTableName')
  3. sp_help yourTableName
  4. SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='YourTableName'
All above queries are used to get columns of the given table.

Q 2:  How to columns data type and NULL to NOT NULL (or NOT NULL to NULL)?

Ans:ALTER TABLE YourTableName ALTER COLUMN Column_Name DataType NOT NULL