Coderock

--------------------------------
link hover image

Visual Studio hot keys change occasionally, specifically F6 vs Ctrl-Shift-B for building

Frontpage calendar image January 9, 2016

You can reassign SHIFT + F6 to build the current project only: 1/ Go to Tools -> Options -> Environment -> Keyboard 2/ Show commands containing: Build.BuildSelection 3/ Focus the field Press shortcut keys & press Shift + F6 to assign it

link hover image

How to get width and height of an image from remote server in asp.net

Frontpage calendar image January 3, 2015

How to get width and height of an image from remote server in asp.net: I am using asp.net 3.5 with c#. I have hosted a site and I want to get width and height of an image from remote server. To avoid error URI formats are not supported, my code look like this: string filePath = string.Format(“http://yoursite.com/Item/{0}”, […]

link hover image

How to remove special characters from string

Frontpage calendar image January 2, 2015

How to remove special characters from string: string str1=Regex.Replace(txtDescription.Text,@”[[]\^$.|?*+(){}%,;><!@#&-+]”,””);

link hover image

How to match a comma separated list of emails with regex?

Frontpage calendar image December 30, 2014

  How to match a comma separated list of emails with regex: < asp:RegularExpressionValidator ID=”reg1″ runat=”server” ErrorMessage=”Wrong email format (separate multiple email by comma [,])” ControlToValidate=”txtToEmail” Display=”Dynamic” ValidationExpression=”^([w+-.%]+@[w-.]+.[A-Za-z]{2,4},?)+$”>< /asp:RegularExpressionValidator>

link hover image

ViewState

Frontpage calendar image December 21, 2014

ViewState is the mechanism that allows state values to be preserved across page postbacks. Values stored in ViewState will be serialized and sent to the client browser as the value of a hidden form input. When you view the page source (in your browser) of a page the uses ViewState, you may see this hidden […]

link hover image

How to disable postback on an asp Button

Frontpage calendar image December 6, 2014

How to disable postback on an asp Button: your javascript return false when it’s done. < asp:button runat="server".... OnClientClick="myfunction(); return false;" / >

link hover image

Name does not exist in the current context

Frontpage calendar image November 23, 2014

Item.aspx This is the phyiscal file -> CodeFile=”Item.aspx.cs” This is the class which handles the events of the page -> Inherits=”item” Jobs.aspx.cs This is the partial class which manages the page events -> public partial class item_class: System.Web.UI.Page The other part of the partial class should be -> public partial class item_class this is usually the […]

link hover image

Prepopulated textbox value to disappears onclick

Frontpage calendar image November 21, 2014

How to prepopulated textbox value to disappears onclick? < asp:TextBox ID=”txtValue” runat=”server” onfocus=”(this.value==’Enter Text’)?this.value=”:this.value=this.value” onblur=”(this.value==”)?this.value=’Enter Text’:this.value=this.value” >< /asp:TextBox>    

link hover image

How to execute clientside javascript function using codebehind function in asp.net

Frontpage calendar image October 26, 2014

You must have a ScriptManager on the page then server-side: ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), “block”, “MyJSScript();”, true);

link hover image

Error: There is a duplicate ‘system.web.extensions/scripting/ webServices/jsonSerialization’ section defined

Frontpage calendar image October 23, 2014

Error: There is a duplicate ‘system.web.extensions/scripting/webServices/jsonSerialization’ section defined Solution If your plan is to deploy to an IIS that has an Application Pool running in .net 4.0 you will need to cleanup the web.config that includes all the section Definitions that point to .net 3.5. The reason this fails is because these section definitions are […]