Thursday, March 29, 2012

Assigning Guids to variables in C#

Assigning Guids to variables in C#

Guid invt_id = new Guid("abcd-efg-etc.....Any Guid String");
Guid invt_id = Guid.Empty;

Wednesday, March 14, 2012

Preventing GridView from reacting to enter button

function disableEnterKey(e)
{
if(e.keyCode == 13)
e.returnValue=false;
e.Cancel=true;
}



asp:GridView ID="grdView1" runat="server"
onkeydown="javascript:disableEnterKey(window.event);"


http://stackoverflow.com/questions/152099/i-want-to-prevent-asp-net-gridview-from-reacting-to-the-enter-button1​

Making a TextBox ReadOnly

Making a TextBox ReadOnly

asp:textbox id="txtItemTotal_Edit" class="TextBoxReadOnlyStyle" text="abcd" enabled="false" enableviewstate="true">' runat="server"> /asp:textbox


If you want your TextBox to behave like a label but need the values retained during a postback i.e, in ViewState then using Enabled="false" and EnableViewState="true" attributes, is one way to do it. You can apply any desirable style to your textbox using css.

Enable Diagnostics on Sharepoint Server

To Get IIS Logs:

1.Go to IISManager->Sites->Look at Site InQuestion->Note the ID of the site.
2.Click on the Site->Feature View->Logging->Note the Directory Path
3.Run your issue.
4.Browse to the Logging Directory and locate the File that ends with the ID of the site and grab It.
To Enable Diagnostics on Sharepoint Server:

1.Go to Central Admin->Monitoring->Reporting->Configure Diagnostic Logging
2.Select All Categories, Set the level to Verbose; and note the Log Path
3.Go to Servics.msc and Restart Sharepoint 2010 Tracing service
4.Run your issue
5.Browse to the log file path and locate your needed log file.
To disable Diagnostics on the server:(Run this in Powershell)

stsadm -o setlogginglevel -default

Enable Scripting on your browser

To allow all Web sites in the Internet zone to run scripts, use the steps that apply to your browser:


Windows Internet Explorer
(all versions except Pocket Internet Explorer)



Note To allow scripting on this Web site only, and to leave scripting disabled in the Internet zone, add this Web site to the Trusted sites zone.

1.On the Tools menu, click Internet Options, and then click the Security tab.
2.Click the Internet zone.
3.If you do not have to customize your Internet security settings, click Default Level. Then do step 4
If you have to customize your Internet security settings, follow these steps:
a. Click Custom Level.
b. In the Security Settings – Internet Zone dialog box, click Enable for Active Scripting in the Scripting section.
4.Click the Back button to return to the previous page, and then click the Refresh button to run scripts.
Got this from http://support.microsoft.com/gp/howtoscript

Get Sharepoint List GUID from Browser

Go to Information Management section in the List Settings and the URL will have the decoded list GUID.

SharePoint Exception: No item exists [url]. It may have been deleted or renamed by another user

By changing the querystring key from id to someother key named like "sid" or "pid" or anything other than "id" made the error go away.

Signing an assembly

http://msdn.microsoft.com/en-us/library/6f05ezxy(v=VS.71).aspx



To create a key pair
•At the command prompt, type the following command:
sn –k
In this command, file name is the name of the output file containing the key pair.
The following example creates a key pair called sgKey.snk.

Copy
sn -k sgKey.snk
If you are using an IDE, such as Visual Studio .NET, to sign an assembly with a strong name, you must understand where the IDE looks for the key file.
For example, Visual Basic .NET looks for the key file in the directory containing the Visual Studio Solution, whereas the C# compiler looks for the key file
in the directory containing the binary. Put the key file in the appropriate project directory and set the file attribute as follows:

VB

[C#][assembly: AssemblyKeyFileAttribute(@"..\..\key.snk")]