A ASP.NET web page goes blank if you inject the javascript alert(); function using the Response.Write from the the code behind.

Here is the fix for it.

private void ShowMessage(string message)

{

StringBuilder scriptBuilder = new StringBuilder("<script language=’javascript’>function window.onload(){");

scriptBuilder.Append("alert(‘" + message + "’);");

scriptBuilder.Append("}</script>");

if (!ClientScript.IsClientScriptBlockRegistered("MyMessage"))

{

ClientScript.RegisterClientScriptBlock(this.GetType(), "MyMessage", scriptBuilder.ToString());

}

}

Advertisements

private void UpdateConnectionString(string ConfigPath)

{

XmlDocument xmlDocument = new XmlDocument();

xmlDocument.Load(ConfigPath);

XmlNode parentNode = xmlDocument.DocumentElement;

if (parentNode.Name == "connectionStrings")

{

foreach (XmlNode childNode in parentNode.ChildNodes)

{

if (childNode.Name == "add" && childNode.Attributes["name"].Value=="MySqlConnection")

{

string sqlConnectionString = childNode.Attributes["connectionString"].Value;

SqlConnectionStringBuilder sqlBuilder = new SqlConnectionStringBuilder(sqlConnectionString);

sqlBuilder.InitialCatalog = "yourDatabaseName";

sqlBuilder.IntegratedSecurity = true;

sqlBuilder.Password = "";

//Change any other attributes using the sqlBuilder object

childNode.Attributes["connectionString"].Value = sqlBuilder.ConnectionString;

}

}

}

xmlDocument.Save(ConfigPath);

}

private string GetOpenPort()

{

int PortStartIndex = 1000;

int PortEndIndex = 2000;

IPGlobalProperties properties = IPGlobalProperties.GetIPGlobalProperties();

IPEndPoint[] tcpEndPoints = properties.GetActiveTcpListeners();

List<int> usedPorts = tcpEndPoints.Select(p => p.Port).ToList<int>();

int unusedPort = 0;

for (int port = PortStartIndex; port < PortEndIndex; port++)

{

if (!usedPorts.Contains(port))

{

unusedPort = port;

break;

}

}

return unusedPort.ToString();

}

private bool PublishWebSite(string SiteName)

{

try

{

string siteName = "YourSiteName";

string applicationPoolName = "ASP.NET v4.0 Classic";

string virtualDirectoryPath = "/";

//Path to the folder of the published code

string virtualDirectoryPhysicalPath = "yourDirectoryPath";

//IP address of current machine where the site is to be published

string ipAddress = "IpAddressOfServer";

//Port to be assigned to the site

string tcpPort = "1109";

//Site name that appears in the URL

string hostHeader = string.Format("www.{0}", siteName);

string applicationPath = "/";

long highestId = 1;

using (ServerManager serverManager = new ServerManager())

{

Site site = serverManager.Sites[siteName];

if (site != null)

{

return false;

}

ApplicationPool appPool = serverManager.ApplicationPools[applicationPoolName];

if (appPool == null)

{

throw new Exception(String.Format("Application Pool: {0} does not exist.", applicationPoolName));

}

highestId = serverManager.Sites.Max(i => i.Id);

highestId++;

site = serverManager.Sites.CreateElement();

site.SetAttributeValue("name", siteName);

site.Id = highestId;

site.Bindings.Clear();

//Assign the IP address , Port and site URL

string bind = ipAddress + ":" + tcpPort + ":" + hostHeader;

Binding binding = site.Bindings.CreateElement();

binding.Protocol = "http";

binding.BindingInformation = bind;

site.Bindings.Add(binding);

Application application = site.Applications.CreateElement();

application.Path = applicationPath;

application.ApplicationPoolName = applicationPoolName;

//Create a virtual directory in IIS

VirtualDirectory vdir = application.VirtualDirectories.CreateElement();

vdir.Path = virtualDirectoryPath;

//Set the physical path of the folder

vdir.PhysicalPath = virtualDirectoryPhysicalPath;

application.VirtualDirectories.Add(vdir);

site.Applications.Add(application);

//Add this new site to the pool of sites in IIS

serverManager.Sites.Add(site);

serverManager.CommitChanges();

}

return true;

}

catch (Exception)

{

return false;

}

}

private bool CopyFolderContents(string SourcePath, string DestinationPath)

{

SourcePath = SourcePath.EndsWith(@"\") ? SourcePath : SourcePath + @"\";

DestinationPath = DestinationPath.EndsWith(@"\") ? DestinationPath : DestinationPath + @"\";

try

{

if (Directory.Exists(SourcePath))

{

if (Directory.Exists(DestinationPath) == false)

{

Directory.CreateDirectory(DestinationPath);

}

foreach (string files in Directory.GetFiles(SourcePath))

{

FileInfo fileInfo = new FileInfo(files);

fileInfo.CopyTo(string.Format(@"{0}\{1}", DestinationPath, fileInfo.Name), true);

}

foreach (string drs in Directory.GetDirectories(SourcePath))

{

DirectoryInfo directoryInfo = new DirectoryInfo(drs);

if (CopyFolderContents(drs, DestinationPath + directoryInfo.Name) == false)

{

return false;

}

}

}

return true;

}

catch (Exception ex)

{

return false;

}

}

I encourage anyone to try to solve it using only its logic skills, since it is a very rewarding experience, especially when its creator declared that “98% of the world population would not be able to solve it”

The Riddle

  1. In a town, there are five houses, each painted with a different color.
  2. In every house leaves a person of different nationality.
  3. Each homeowner drink a different beverage, smokes a different brand of cigar, and owns a different type of pet.

The Question

Who owns the fishes?

Hints

  1. The Brit lives in a red house.
  2. The Swede keeps dogs as pets.
  3. The Dane drinks tea.
  4. The Green house is next to, and on the left of the White house.
  5. The owner of the Green house drinks coffee.
  6. The person who smokes Pall Mall rears birds.
  7. The owner of the Yellow house smokes Dunhill.
  8. The man living in the center house drinks milk.
  9. The Norwegian lives in the first house.
  10. The man who smokes Blends lives next to the one who keeps cats.
  11. The man who keeps horses lives next to the man who smokes Dunhill.
  12. The man who smokes Blue Master drinks beer.
  13. The German smokes Prince.
  14. The Norwegian lives next to the blue house.
  15. The man who smokes Blends has a neighbor who drinks water.

NOTE : The main point of the Einstein’s Riddle is that 98% of human beings are unable to hold in memory more than 9 information units simultaneously ( whatever they could be ). Indeed, try to solve it using only your brain, and NOT using any other means ( such as paper, pencil, computers, e t. c.). I bet you will at least making significant efforts ( if not reject to solve it at all )…

int x = 200;

int y = 300;

Response.Write("Before swap ");

Response.Write("x=" + x + ",y=" + y);

Response.Write("

How to Center a Table inside a Div using CSS

If you have been looking for a simple way to center a table inside a div, then here it is

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
 <title></title>
 <style type="text/css">
 #divOne
 {

 width:400px; 
 text-align:center; 
 border:dotted 1px black; 
 }
 #tblOne
 {
 width:200px; 
 margin:0 auto
 border: solid 1px black; 
 }
 </style>
</head>
<body>
 <div id="divOne">
 <table id="tblOne">
<tr>
<td>R1C1</td>
 <td>R1C2</td>
 <td>R1C3</td>
 </tr>
 <tr>
 <td>R2C1</td>
 <td>R2C2</td>
 <td>R2C3</td>
 </tr>
</table>
</div>
</body>
</html>

I have seen lot of people missing out on the margin:auto property. Setting margin to auto is the correct way to center a table and works in ‘most’ of the browsers. The border is just for illustration purposes and is not required.

OUTPUT

http://tutorialzine.com/2010/06/making-first-chrome-extension/

You need to AJAX enable a asp.net application to use the progress bar control.

Place this asp.net script on the master page or the individual page as required and the progress bar will be displayed during page is loading.

<asp:ScriptManager ID="ScriptManager1" runat="server">

</asp:ScriptManager>

<asp:UpdateProgress ID="Updateprogress1" runat="server">

<ProgressTemplate>

<iframe frameborder="0" src="about:blank" style="border: 0px; position: absolute;

z-index: 9; left: 0px; top: 0px; width: expression(this.offsetParent.scrollWidth);

height: expression(this.offsetParent.scrollHeight); filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=0, FinishOpacity=0, Style=0, StartX=0, FinishX=100, StartY=0, FinishY=100);">

</iframe>

<div style="position: absolute; z-index: 10; left: expression((this.offsetParent.clientWidth/2)-(this.clientWidth/2)+this.offsetParent.scrollLeft);

top: expression((this.offsetParent.clientHeight/2)-(this.clientHeight/2)+this.offsetParent.scrollTop);">

<table border="0" cellpadding="0" style="border-collapse: collapse" width="100" id="tblloder"

runat="server">

<tr>

<td height="8">

</td>

</tr>

<tr>

<td align="center">

<img alt="" border="0" src="images/progress-bar.gif"></td>

</tr>

<tr>

<td height="6">

</td>

</tr>

</table>

</div>

</ProgressTemplate>

</asp:UpdateProgress>


Many times we need to search the database for e.g. to search the database for Customer names.

So the general Query to search a name ’Chapell’ will be

SELECT CustomerName FROM t_CustomerMaster WHERE CustomerName =’Chapell’

Now imagine that the user searching the database enters ‘Chapple’ in the textbox and hits enter. He will hit enter and will not get any results. So usually we use the LIKE operator in the WHERE clause and search for a substring.

SELECT CustomerName FROM t_CustomerMaster WHERE CustomerName LIKE ’%Chap%’

So this one will work and return all the names that contain the substring ‘Chap’ . So the result set can contain anything like Chapel, Chapele, Richap etc.

But will this search query still work if I search for ‘Chipell’ instead of ‘Chapell’ ?

The answer to his question is the SOUNDEX() function in Transact SQL.

The SOUNDEX() returns a four digit code for a varchar value passed to it. The same code is returned for all those names whose pronounciation is similar.

For example SOUNDEX(‘Smith’), SOUNDEX(‘Smythe’),SOUNDEX(‘Smithe’) will return the same code

More information on SOUNDEX() can be found here http://msdn.microsoft.com/en-us/library/aa259235(SQL.80).aspx

As a result the search query can be tuned to return the result set for ‘Chapell’ even if you search for ‘Chipell’. So re-constructing our search query by combining the power of LIKE and SOUNDEX() will return the same results even if the spelling Of ‘Chapell’ is changed

SELECT CustomerName

FROM t_CustomerMaster

WHERE (CustomerName LIKE ’%Chapell%’ OR (SOUNDEX(CustomerName) LIKE SOUNDEX(’%Chapell%’)))

The above query will return the same result set even if you use Chap,Chapel,Chapelle, Chipell instead of Chapell

Step 1:Populate the ViewState with the datasource of the gridview in the !Page.IsPostback event .

Step 2: In Gridview set AllowSorting="true"

Step: 3: Add the sortexpression="ColumnName"

Step 4: Handle the Onsorting event of the grid on the server side as follows:

protected void grdRoomTypeMaster_OnSorting(object sender, GridViewSortEventArgs e)
{
DataTable dtGridData = ViewState["grdDataSource"] as DataTable;
DataView dvGridDataView = dtGridData.DefaultView;
string strSortOrder = "";
if (ViewState["SortOrder"]==null)
{
ViewState["SortOrder"] = "asc";
}
if (ViewState["SortOrder"].ToString() == "asc")
{
ViewState["SortOrder"] = "desc";
strSortOrder = "desc";
}
else if (ViewState["SortOrder"].ToString() == "desc")
{
ViewState["SortOrder"] = "asc";
strSortOrder = "asc";
}
dvGridDataView.Sort = e.SortExpression + " " + strSortOrder;
dtGridData = dvGridDataView.ToTable();

grdRoomTypeMaster.DataSource = dtGridData;
grdRoomTypeMaster.DataBind();
}

Thanks Justin for his post and VB.NET code on

http://geekswithblogs.net/phoenix/archive/2009/07/02/gridview-sorting-with-datatables.aspx

You can get the values from a named column in the DataTable using a single line of code in LINQ.

Steps:

1. Convert the DataTable object to Enumerable()

2. Apply the select clause with the column name as field name .

3. Cast it to a string array.

string[] strSummCities = dtTemp1.AsEnumerable().Select(s => s.Field<string>("City")).ToArray<string>();

try

{

ConnectionOptions connection = new ConnectionOptions();

connection.Username = userNameBox.Text;

connection.Password = passwordBox.Text;

connection.Authority = "ntlmdomain:Finance123";

ManagementScope scope = new ManagementScope(

"\\dell417\root\CIMV2", connection);

scope.Connect();

ObjectQuery query= new ObjectQuery(

"SELECT * FROM Win32_DiskDrive");

ManagementObjectSearcher searcher =

new ManagementObjectSearcher(scope, query);

foreach (ManagementObject queryObj in searcher.Get())

{

Console.WriteLine("");

Console.WriteLine("Win32_DiskDrive instance");

Console.WriteLine("");

Console.WriteLine("Availability: {0}", queryObj["Availability"]);

Console.WriteLine("BytesPerSector: {0}", queryObj["BytesPerSector"]);

if(queryObj["Capabilities"] == null)

Console.WriteLine("Capabilities: {0}", queryObj["Capabilities"]);

else

{

UInt16[] arrCapabilities = (UInt16[])(queryObj["Capabilities"]);

foreach (UInt16 arrValue in arrCapabilities)

{

Console.WriteLine("Capabilities: {0}", arrValue);

}

}

if(queryObj["CapabilityDescriptions"] == null)

Console.WriteLine("CapabilityDescriptions: {0}", queryObj["CapabilityDescriptions"]);

else

{

String[] arrCapabilityDescriptions = (String[])(queryObj["CapabilityDescriptions"]);

foreach (String arrValue in arrCapabilityDescriptions)

{

Console.WriteLine("CapabilityDescriptions: {0}", arrValue);

}

}

Console.WriteLine("Caption: {0}", queryObj["Caption"]);

Console.WriteLine("CompressionMethod: {0}", queryObj["CompressionMethod"]);

Console.WriteLine("ConfigManagerErrorCode: {0}", queryObj["ConfigManagerErrorCode"]);

Console.WriteLine("ConfigManagerUserConfig: {0}", queryObj["ConfigManagerUserConfig"]);

Console.WriteLine("CreationClassName: {0}", queryObj["CreationClassName"]);

Console.WriteLine("DefaultBlockSize: {0}", queryObj["DefaultBlockSize"]);

Console.WriteLine("Description: {0}", queryObj["Description"]);

Console.WriteLine("DeviceID: {0}", queryObj["DeviceID"]);

Console.WriteLine("ErrorCleared: {0}", queryObj["ErrorCleared"]);

Console.WriteLine("ErrorDescription: {0}", queryObj["ErrorDescription"]);

Console.WriteLine("ErrorMethodology: {0}", queryObj["ErrorMethodology"]);

Console.WriteLine("Index: {0}", queryObj["Index"]);

Console.WriteLine("InstallDate: {0}", queryObj["InstallDate"]);

Console.WriteLine("InterfaceType: {0}", queryObj["InterfaceType"]);

Console.WriteLine("LastErrorCode: {0}", queryObj["LastErrorCode"]);

Console.WriteLine("Manufacturer: {0}", queryObj["Manufacturer"]);

Console.WriteLine("MaxBlockSize: {0}", queryObj["MaxBlockSize"]);

Console.WriteLine("MaxMediaSize: {0}", queryObj["MaxMediaSize"]);

Console.WriteLine("MediaLoaded: {0}", queryObj["MediaLoaded"]);

Console.WriteLine("MediaType: {0}", queryObj["MediaType"]);

Console.WriteLine("MinBlockSize: {0}", queryObj["MinBlockSize"]);

Console.WriteLine("Model: {0}", queryObj["Model"]);

Console.WriteLine("Name: {0}", queryObj["Name"]);

Console.WriteLine("NeedsCleaning: {0}", queryObj["NeedsCleaning"]);

Console.WriteLine("NumberOfMediaSupported: {0}", queryObj["NumberOfMediaSupported"]);

Console.WriteLine("Partitions: {0}", queryObj["Partitions"]);

Console.WriteLine("PNPDeviceID: {0}", queryObj["PNPDeviceID"]);

if(queryObj["PowerManagementCapabilities"] == null)

Console.WriteLine("PowerManagementCapabilities: {0}", queryObj["PowerManagementCapabilities"]);

else

{

UInt16[] arrPowerManagementCapabilities = (UInt16[])(queryObj["PowerManagementCapabilities"]);

foreach (UInt16 arrValue in arrPowerManagementCapabilities)

{

Console.WriteLine("PowerManagementCapabilities: {0}", arrValue);

}

}

Console.WriteLine("PowerManagementSupported: {0}", queryObj["PowerManagementSupported"]);

Console.WriteLine("SCSIBus: {0}", queryObj["SCSIBus"]);

Console.WriteLine("SCSILogicalUnit: {0}", queryObj["SCSILogicalUnit"]);

Console.WriteLine("SCSIPort: {0}", queryObj["SCSIPort"]);

Console.WriteLine("SCSITargetId: {0}", queryObj["SCSITargetId"]);

Console.WriteLine("SectorsPerTrack: {0}", queryObj["SectorsPerTrack"]);

Console.WriteLine("Signature: {0}", queryObj["Signature"]);

Console.WriteLine("Size: {0}", queryObj["Size"]);

Console.WriteLine("Status: {0}", queryObj["Status"]);

Console.WriteLine("StatusInfo: {0}", queryObj["StatusInfo"]);

Console.WriteLine("SystemCreationClassName: {0}", queryObj["SystemCreationClassName"]);

Console.WriteLine("SystemName: {0}", queryObj["SystemName"]);

Console.WriteLine("TotalCylinders: {0}", queryObj["TotalCylinders"]);

Console.WriteLine("TotalHeads: {0}", queryObj["TotalHeads"]);

Console.WriteLine("TotalSectors: {0}", queryObj["TotalSectors"]);

Console.WriteLine("TotalTracks: {0}", queryObj["TotalTracks"]);

Console.WriteLine("TracksPerCylinder: {0}", queryObj["TracksPerCylinder"]);

}

Close();

}

catch(ManagementException err)

{

MessageBox.Show("An error occurred while querying for WMI data: " + err.Message);

}

catch(System.UnauthorizedAccessException unauthorizedErr)

{

MessageBox.Show("Connection error (user name or password might be incorrect): " + unauthorizedErr.Message);

}

try

{

ConnectionOptions connection = new ConnectionOptions();

connection.Username = userNameBox.Text;

connection.Password = passwordBox.Text;

connection.Authority = "ntlmdomain:Finance123";

ManagementScope scope = new ManagementScope(

"\\dell417\root\CIMV2", connection);

scope.Connect();

ObjectQuery query= new ObjectQuery(

"SELECT * FROM Win32_DirectorySpecification");

ManagementObjectSearcher searcher =

new ManagementObjectSearcher(scope, query);

foreach (ManagementObject queryObj in searcher.Get())

{

Console.WriteLine("");

Console.WriteLine("Win32_DirectorySpecification instance");

Console.WriteLine("");

Console.WriteLine("Caption: {0}", queryObj["Caption"]);

Console.WriteLine("CheckID: {0}", queryObj["CheckID"]);

Console.WriteLine("CheckMode: {0}", queryObj["CheckMode"]);

Console.WriteLine("DefaultDir: {0}", queryObj["DefaultDir"]);

Console.WriteLine("Description: {0}", queryObj["Description"]);

Console.WriteLine("Directory: {0}", queryObj["Directory"]);

Console.WriteLine("DirectoryPath: {0}", queryObj["DirectoryPath"]);

Console.WriteLine("DirectoryType: {0}", queryObj["DirectoryType"]);

Console.WriteLine("Name: {0}", queryObj["Name"]);

Console.WriteLine("SoftwareElementID: {0}", queryObj["SoftwareElementID"]);

Console.WriteLine("SoftwareElementState: {0}", queryObj["SoftwareElementState"]);

Console.WriteLine("TargetOperatingSystem: {0}", queryObj["TargetOperatingSystem"]);

Console.WriteLine("Version: {0}", queryObj["Version"]);

}

Close();

}

catch(ManagementException err)

{

MessageBox.Show("An error occurred while querying for WMI data: " + err.Message);

}

catch(System.UnauthorizedAccessException unauthorizedErr)

{

MessageBox.Show("Connection error (user name or password might be incorrect): " + unauthorizedErr.Message);

}

try

{

ConnectionOptions connection = new ConnectionOptions();

connection.Username = userNameBox.Text;

connection.Password = passwordBox.Text;

connection.Authority = "ntlmdomain:Finance123";

ManagementScope scope = new ManagementScope(

"\\dell417\root\CIMV2", connection);

scope.Connect();

ObjectQuery query= new ObjectQuery(

"SELECT * FROM Win32_Directory");

ManagementObjectSearcher searcher =

new ManagementObjectSearcher(scope, query);

foreach (ManagementObject queryObj in searcher.Get())

{

Console.WriteLine("");

Console.WriteLine("Win32_Directory instance");

Console.WriteLine("");

Console.WriteLine("AccessMask: {0}", queryObj["AccessMask"]);

Console.WriteLine("Archive: {0}", queryObj["Archive"]);

Console.WriteLine("Caption: {0}", queryObj["Caption"]);

Console.WriteLine("Compressed: {0}", queryObj["Compressed"]);

Console.WriteLine("CompressionMethod: {0}", queryObj["CompressionMethod"]);

Console.WriteLine("CreationClassName: {0}", queryObj["CreationClassName"]);

Console.WriteLine("CreationDate: {0}", queryObj["CreationDate"]);

Console.WriteLine("CSCreationClassName: {0}", queryObj["CSCreationClassName"]);

Console.WriteLine("CSName: {0}", queryObj["CSName"]);

Console.WriteLine("Description: {0}", queryObj["Description"]);

Console.WriteLine("Drive: {0}", queryObj["Drive"]);

Console.WriteLine("EightDotThreeFileName: {0}", queryObj["EightDotThreeFileName"]);

Console.WriteLine("Encrypted: {0}", queryObj["Encrypted"]);

Console.WriteLine("EncryptionMethod: {0}", queryObj["EncryptionMethod"]);

Console.WriteLine("Extension: {0}", queryObj["Extension"]);

Console.WriteLine("FileName: {0}", queryObj["FileName"]);

Console.WriteLine("FileSize: {0}", queryObj["FileSize"]);

Console.WriteLine("FileType: {0}", queryObj["FileType"]);

Console.WriteLine("FSCreationClassName: {0}", queryObj["FSCreationClassName"]);

Console.WriteLine("FSName: {0}", queryObj["FSName"]);

Console.WriteLine("Hidden: {0}", queryObj["Hidden"]);

Console.WriteLine("InstallDate: {0}", queryObj["InstallDate"]);

Console.WriteLine("InUseCount: {0}", queryObj["InUseCount"]);

Console.WriteLine("LastAccessed: {0}", queryObj["LastAccessed"]);

Console.WriteLine("LastModified: {0}", queryObj["LastModified"]);

Console.WriteLine("Name: {0}", queryObj["Name"]);

Console.WriteLine("Path: {0}", queryObj["Path"]);

Console.WriteLine("Readable: {0}", queryObj["Readable"]);

Console.WriteLine("Status: {0}", queryObj["Status"]);

Console.WriteLine("System: {0}", queryObj["System"]);

Console.WriteLine("Writeable: {0}", queryObj["Writeable"]);

}

Close();

}

catch(ManagementException err)

{

MessageBox.Show("An error occurred while querying for WMI data: " + err.Message);

}

catch(System.UnauthorizedAccessException unauthorizedErr)

{

MessageBox.Show("Connection error (user name or password might be incorrect): " + unauthorizedErr.Message);

}

try

{

ConnectionOptions connection = new ConnectionOptions();

connection.Username = userNameBox.Text;

connection.Password = passwordBox.Text;

connection.Authority = "ntlmdomain:Finance123";

ManagementScope scope = new ManagementScope(

"\\dell417\root\CIMV2", connection);

scope.Connect();

ObjectQuery query= new ObjectQuery(

"SELECT * FROM Win32_DesktopMonitor");

ManagementObjectSearcher searcher =

new ManagementObjectSearcher(scope, query);

foreach (ManagementObject queryObj in searcher.Get())

{

Console.WriteLine("");

Console.WriteLine("Win32_DesktopMonitor instance");

Console.WriteLine("");

Console.WriteLine("Availability: {0}", queryObj["Availability"]);

Console.WriteLine("Bandwidth: {0}", queryObj["Bandwidth"]);

Console.WriteLine("Caption: {0}", queryObj["Caption"]);

Console.WriteLine("ConfigManagerErrorCode: {0}", queryObj["ConfigManagerErrorCode"]);

Console.WriteLine("ConfigManagerUserConfig: {0}", queryObj["ConfigManagerUserConfig"]);

Console.WriteLine("CreationClassName: {0}", queryObj["CreationClassName"]);

Console.WriteLine("Description: {0}", queryObj["Description"]);

Console.WriteLine("DeviceID: {0}", queryObj["DeviceID"]);

Console.WriteLine("DisplayType: {0}", queryObj["DisplayType"]);

Console.WriteLine("ErrorCleared: {0}", queryObj["ErrorCleared"]);

Console.WriteLine("ErrorDescription: {0}", queryObj["ErrorDescription"]);

Console.WriteLine("InstallDate: {0}", queryObj["InstallDate"]);

Console.WriteLine("IsLocked: {0}", queryObj["IsLocked"]);

Console.WriteLine("LastErrorCode: {0}", queryObj["LastErrorCode"]);

Console.WriteLine("MonitorManufacturer: {0}", queryObj["MonitorManufacturer"]);

Console.WriteLine("MonitorType: {0}", queryObj["MonitorType"]);

Console.WriteLine("Name: {0}", queryObj["Name"]);

Console.WriteLine("PixelsPerXLogicalInch: {0}", queryObj["PixelsPerXLogicalInch"]);

Console.WriteLine("PixelsPerYLogicalInch: {0}", queryObj["PixelsPerYLogicalInch"]);

Console.WriteLine("PNPDeviceID: {0}", queryObj["PNPDeviceID"]);

if(queryObj["PowerManagementCapabilities"] == null)

Console.WriteLine("PowerManagementCapabilities: {0}", queryObj["PowerManagementCapabilities"]);

else

{

UInt16[] arrPowerManagementCapabilities = (UInt16[])(queryObj["PowerManagementCapabilities"]);

foreach (UInt16 arrValue in arrPowerManagementCapabilities)

{

Console.WriteLine("PowerManagementCapabilities: {0}", arrValue);

}

}

Console.WriteLine("PowerManagementSupported: {0}", queryObj["PowerManagementSupported"]);

Console.WriteLine("ScreenHeight: {0}", queryObj["ScreenHeight"]);

Console.WriteLine("ScreenWidth: {0}", queryObj["ScreenWidth"]);

Console.WriteLine("Status: {0}", queryObj["Status"]);

Console.WriteLine("StatusInfo: {0}", queryObj["StatusInfo"]);

Console.WriteLine("SystemCreationClassName: {0}", queryObj["SystemCreationClassName"]);

Console.WriteLine("SystemName: {0}", queryObj["SystemName"]);

}

Close();

}

catch(ManagementException err)

{

MessageBox.Show("An error occurred while querying for WMI data: " + err.Message);

}

catch(System.UnauthorizedAccessException unauthorizedErr)

{

MessageBox.Show("Connection error (user name or password might be incorrect): " + unauthorizedErr.Message);

}

try

{

ConnectionOptions connection = new ConnectionOptions();

connection.Username = userNameBox.Text;

connection.Password = passwordBox.Text;

connection.Authority = "ntlmdomain:Finance123";

ManagementScope scope = new ManagementScope(

"\\dell417\root\CIMV2", connection);

scope.Connect();

ObjectQuery query= new ObjectQuery(

"SELECT * FROM Win32_Desktop");

ManagementObjectSearcher searcher =

new ManagementObjectSearcher(scope, query);

foreach (ManagementObject queryObj in searcher.Get())

{

Console.WriteLine("");

Console.WriteLine("Win32_Desktop instance");

Console.WriteLine("");

Console.WriteLine("BorderWidth: {0}", queryObj["BorderWidth"]);

Console.WriteLine("Caption: {0}", queryObj["Caption"]);

Console.WriteLine("CoolSwitch: {0}", queryObj["CoolSwitch"]);

Console.WriteLine("CursorBlinkRate: {0}", queryObj["CursorBlinkRate"]);

Console.WriteLine("Description: {0}", queryObj["Description"]);

Console.WriteLine("DragFullWindows: {0}", queryObj["DragFullWindows"]);

Console.WriteLine("GridGranularity: {0}", queryObj["GridGranularity"]);

Console.WriteLine("IconSpacing: {0}", queryObj["IconSpacing"]);

Console.WriteLine("IconTitleFaceName: {0}", queryObj["IconTitleFaceName"]);

Console.WriteLine("IconTitleSize: {0}", queryObj["IconTitleSize"]);

Console.WriteLine("IconTitleWrap: {0}", queryObj["IconTitleWrap"]);

Console.WriteLine("Name: {0}", queryObj["Name"]);

Console.WriteLine("Pattern: {0}", queryObj["Pattern"]);

Console.WriteLine("ScreenSaverActive: {0}", queryObj["ScreenSaverActive"]);

Console.WriteLine("ScreenSaverExecutable: {0}", queryObj["ScreenSaverExecutable"]);

Console.WriteLine("ScreenSaverSecure: {0}", queryObj["ScreenSaverSecure"]);

Console.WriteLine("ScreenSaverTimeout: {0}", queryObj["ScreenSaverTimeout"]);

Console.WriteLine("SettingID: {0}", queryObj["SettingID"]);

Console.WriteLine("Wallpaper: {0}", queryObj["Wallpaper"]);

Console.WriteLine("WallpaperStretched: {0}", queryObj["WallpaperStretched"]);

Console.WriteLine("WallpaperTiled: {0}", queryObj["WallpaperTiled"]);

}

Close();

}

catch(ManagementException err)

{

MessageBox.Show("An error occurred while querying for WMI data: " + err.Message);

}

catch(System.UnauthorizedAccessException unauthorizedErr)

{

MessageBox.Show("Connection error (user name or password might be incorrect): " + unauthorizedErr.Message);

}

min-height:expression( document.body.clientHeight +’px’);

The information in this email is confidential and may be legally privileged. It is intended solely for the addressee and access to it by anyone else is unauthorized. If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken based on it, is strictly prohibited and may be unlawful.

Include this HTML just after the <form > tag in the web page.

<input type="hidden" id="MicrosoftILITWebEmbedInfo" attachmode="optout" value=""/>

<script type="text/javascript" src="http://ilit.microsoft.com/bookmarklet/script/Marathi.js"

defer="defer"></script>

public class SharedObjectContext
{
private readonly WestwindEntities context;

#region Singleton Pattern

// Static members are lazily initialized.
// .NET guarantees thread safety for static initialization.
private static readonly SharedObjectContext instance = new SharedObjectContext();

// Make the constructor private to hide it.
// This class adheres to the singleton pattern.
private SharedObjectContext()
{
// Create the ObjectContext.
context = new WestwindEntities();
}

// Return the single instance of the ClientSessionManager type.
public static SharedObjectContext Instance
{
get
{
return instance;
}
}

#endregion

public WestwindEntities Context
{
get
{
return context;
}
}
}

for ASP.NET

public static class ObjectContextPerHttpRequest
{
public static WestwindEntities Context
{
get
{
string objectContextKey = HttpContext.Current.GetHashCode().ToString("x");
if (!HttpContext.Current.Items.Contains(objectContextKey))
{
HttpContext.Current.Items.Add(objectContextKey, new WestwindEntities());
}
return HttpContext.Current.Items[objectContextKey] as WestwindEntities;
}
}
}

Here’s a handy query for finding duplicates in a table. Suppose you want to find all email addresses in a table that exist more than once:

SELECT email,

COUNT(email) AS NumOccurrences

FROM users

GROUP BY email

HAVING ( COUNT(email) > 1 )

You could also use this technique to find rows that occur exactly once:

SELECT email

FROM users

GROUP BY email

HAVING ( COUNT(email) = 1 )

His workplace resume reads something like this:

Work History
• Avoiding responsibility for tasks
• Doing less when asked for more
• Missing deadlines
• Withholding information

Professional Activities
• Leaving notes and using e-mail to avoid face-to-face communication
• Arriving late to work; extending lunch break
• Using sick days during major team projects
• Resisting suggestions for change or improvement

Special Qualifications
• "Forgetting" and "misplacing" important documents
• Embarrassing co-workers during meetings and presentations
• Justifying behavior with plausible explanations
• Consistently behaving this way across most workplace situations

Does someone in your office boast these passive aggressive credentials?

Passive aggression is a deliberate and masked way of expressing hidden anger. In many workplace settings, where adults spend the majority of their waking hours and corporate hierarchies inhibit direct expression of feelings, the passive aggressive employee is able to sabotage everything from individual deadlines to department morale to organizational productivity. It is critical that employers be able to recognize passive aggressive behaviors in the workplace before they negatively impact output and efficiency. Do any of your workers exhibit these common tactics of passive aggressive workers?

Temporary Compliance
The passive aggressive employee often feels underappreciated and expresses his underlying anger through temporary compliance. Though he verbally agrees to a task, he behaviorally delays its completion, by procrastinating, "forgetting" important deadlines, "misplacing" documents, or arriving late. For the passive aggressive worker who feels under-acknowledged by colleagues and management, acts of temporary compliance are most satisfying.

Intentional Inefficiency
The passive aggressive worker feels it is more important to express his covert hostility than to maintain his appearance of professional competence. He uses intentional inefficiency to complete work in a purposefully unacceptable way:

Tom felt snubbed when passed over for a promotion. He decided to go about his job in a new way; the quantity of his output did not change, but his work became marred with missed details, important omissions, and critical errors. Though Tom never missed a deadline and took on every requested assignment, the quality of his final product had a way of creating embarrassing moments for unsuspecting supervisors caught presenting misinformation.

To protect your office from the passive aggressive saboteur, look out for employees whose work is consistently at or below minimum standards, who insists "no one told me," and who personalizes any confrontations from authority, playing up their role as victim.

Letting a Problem Escalate
Teamwork and communication are key to productivity in the workplace. When a passive aggressive employee withholds important information or deliberately fails to stop a momentary glitch from turning into an irreversible gaffe, entire operations can be halted or even shut down. The (mis)use of sick days is an area of particular vulnerability in the workplace:

Brenda called in sick the day before a major deadline, knowing that her presence was critical to her department’s success. She took great pleasure in single-handedly foiling the quarterly report and in the resulting company-wide affirmation that without her, the department could not succeed.

Sabotage is the name of the game for the passive aggressive employee who justifies her characteristic crimes of omission by saying, "I didn’t do anything."

Hidden but Conscious Revenge
In contrast to the inaction that marks the previous tactic, some workers use covert actions to get back at superiors against whom they hold a grudge. The passive aggressive employee is keenly aware that the person with whom he is angry has enough power and authority to make his professional life miserable, so he decides it is not safe to confront him directly. Whether it be through spreading gossip that maligns the boss’s reputation or planting a computer virus that shuts down office IT systems for a week, the passive aggressive employee feels justified in taking secret revenge in the workplace.

By the nature of their covert acts, passive aggressive employees are skilled at evading the long arm of the workplace law. Unchecked, a compliant rule-breaker can have a major impact on an organization’s productivity and morale. When employers understand the warning signs and quickly recognize passive aggressive patterns, they can protect their workplaces from being the unwitting victim of this ideal office crime.

Managing Passive Aggression in Workplaces

If you are a veteran of “office wars,” then perhaps you have experienced a lot of backstabbing, sabotage and nasty behaviors, right? As a normal consequence, you think that there is very little to be done to control this competitive behavior. You have become resigned to a certain degree of aggression every day in the office.

The ones that bother most are not the openly competitive people, because you know what they want, and there are no surprises in them getting ahead to snag the best projects, and commissions. What you don’t prepare for is the slow sabotage of certain people who feign cooperation and dedication, only to produce consistent failures.

If you were expecting someone to do a shared project, and your own evaluation is supposed to be in the whole project, but one part is not forthcoming, then what do you do? There were lots of promises, guarantees and strong words, but no results. And you don’t know if to believe this person, or to accept that the project is doomed and you are responsible very soon to report a failure.

Here is when the rubber meets the road: you are realizing that his delay is intentional and focused on making you fail! Difficult to believe, but no other plausible explanations are around, so you need to accept you’ve been blindsided by this person.

What do you do: have a strong discussion or say nothing? Knowing that a passive aggressive person won’t fight back, they can clam up, give you the cold shoulder, tell you what you want to hear, or burst into tears and run away.

If you show your anger, the PA will be less cooperative, stop communicating and confirm that you are his enemy, so becoming more hostile and resentful, even to the point of planning his revenge. Then, how do you manage this potentially explosive situation?

For some reason we have been conditioned to avoid any kind of open confrontation, even the healthy ones, and to try to keep up with a forced situation that doesn’t deserve to be called “peace,” but an angry truce.

Let’s go back to the basic situation, where you are a team leader, or a manager, and you have someone in your team behaving in this way. Of course, you know that this person is immature, that his PA behavior is a defense mechanism, and all that. Anyhow, this person is not responding to you!

Now, it becomes really personal…and you shift from an outsider’s view to a very interested insider, because the action is against you or your work objectives…You suddenly realize that the passive aggressive person’s goal is an attempt to control his environment, meaning by that you and your responses. He is controlling at least the time of delivery of this shared project!

What can you do? If you have identified already the presence of this kind of behavior, you know that you have always to design an alternative plan “B” which can provide you with the extra help needed to deliver the project done in time and quality.

If not, then the choice is to continue expecting from him the delivery of his task, or replacing him. In both ways, the “solution” will leave a bad taste in the relationship. The first lesson, “never trust your own evaluation to the hands of other person who cold be passive aggressive,” is learnt. In brief, control your expectations, parcel out important tasks so there are several responsible people involved, and re-check frequently to see how much delay the PA can generate before you stop him.

A psychological self-test for everyone.

Psychological Self Test.xlsx

A wise man once sat in the audience & cracked a joke.
All laughed like crazy. After a moment he cracked the same joke again and a little less people laughed this time.
He cracked the same joke again & again, When there was no laughter in the crowd,
he smiled and said

"When u can’t laugh on the same joke again & again, then why do u keep crying over the same thing over and over again.

‘Forget the past & move on’…