Archive for the ‘Programmers’ Category


/// The main entry point for the application.



staticvoid Main()





//Application.Run(new MainForm());

Application.ThreadException += newThreadExceptionEventHandler(Application_ThreadException);

AppDomain.CurrentDomain.UnhandledException += newUnhandledExceptionEventHandler(CurrentDomain_UnhandledException);



staticvoid CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)


MessageBox.Show(“CurrentDomain_UnhandledException: “ + e.ExceptionObject.ToString());


staticvoid Application_ThreadException(object sender, ThreadExceptionEventArgs e)


MessageBox.Show(“Application_ThreadException: “ + e.Exception.Message);



Read Full Post »


        private void txtTest_TextChanged(object sender, EventArgs e)












        /// <summary>


        /// To Dynamically increase height of text box


        /// </summary>


        /// <param name=”sender”></param>


        ///By Sujeet on 24th Aug 2011


        static public void SetAutoHightforTextBox(object sender)




            //Use this method on TextChanged


            //Must set WordWrap to true to work this.


            //Note: Please set text box MinHeight, MaxHeight, MinWidth for better result.


            int i_gl_acc_height = 20; int i_gl_acc_char_length = 1; double i_BreakPoint = 50;


            int i_no_lines = 1;



            //Font height & width


            int i_FontHeight = ((TextBox)sender).Font.Height;


            float i_FontWidth = ((TextBox)sender).Font.SizeInPoints;






            i_gl_acc_char_length = txtTest.Text.Length;


            i_BreakPoint = txtTest.Width / i_FontWidth;


            i_no_lines = Convert.ToInt32(i_gl_acc_char_length / i_BreakPoint) + 1;


            i_gl_acc_height = (i_FontHeight + 6) * i_no_lines;




            //Setting Height


            txtTest.Height = i_gl_acc_height;






Read Full Post »

If your are getting following exception

“Procedure or function ‘*’ expects parameter ‘*’, which was not supplied. “

while it’s already supplied.

then check if you forgot to set “CommandType” Property to “StoredProcedure”.


cmdUser.CommandType = CommandType.StoredProcedure;    /*This is missing. */

Read Full Post »

ScriptManager.RegisterStartupScript(this.UpdatePanelPublish, typeof(Page), “Message”, “alert(‘Oops! Map is not published successfully. Please contact your software vendor with error Log.’)”, true);

Read Full Post »

Created a user defined function in SQL Server 2005 :
CREATE function udf_GetMasterSiteTypeName
@ParkSiteTypeName Varchar(128),
@ParkCampid Varchar(128) = null
returns varchar(128)
declare @id varchar(128)
Select @id=Upper(Ltrim(Rtrim([Name]))) from tblSitetypeMaster M
INNER JOIN tblparksitetype T ON M.SiteTypeId=T.SiteTypeId
Where T.ParkCampid = isNull(@ParkCampid, ‘%’)
and Upper(Ltrim(Rtrim(T.ParkSiteTypeName))) = Upper(Ltrim(Rtrim(@ParkSiteTypeName)))

return @id

Called above UDF in C#.Net :

public string GetGlobalSiteTypeName(string SiteTypeName, string CampID)
string retValue = “”;
SqlCommand cmdGetGlobalSiteType = new SqlCommand(“udf_GetMasterSiteTypeName”, Connection.GetConnection());
cmdGetGlobalSiteType.CommandType = CommandType.StoredProcedure;
cmdGetGlobalSiteType.Parameters.Add(“@ParkSiteTypeName”, SqlDbType.VarChar).Value = SiteTypeName;
cmdGetGlobalSiteType.Parameters.Add(“@ParkCampid”, SqlDbType.VarChar).Value = CampID;
SqlParameter prmSiteTypeName = new SqlParameter(“@GlobalSiteType”, SqlDbType.VarChar);
prmSiteTypeName.Direction = ParameterDirection.ReturnValue;
if (Convert.ToString(prmSiteTypeName.Value) != “”)
retValue = Convert.ToString(prmSiteTypeName.Value);

catch (Exception)

return retValue;

Read Full Post »

If there is some issue in using ItemCommand of a grid to handle bubble event, you can use event of controls directly and access data at row level. See below code :

protected void radDatePickerFrom_SelectedDateChanged(object sender, Telerik.Web.UI.Calendar.SelectedDateChangedEventArgs e)
RadDatePicker radDatePickerFrom = (RadDatePicker)sender;
GridDataItem item = (GridDataItem)radDatePickerFrom.NamingContainer;
RadDatePicker radDatePickerTo = (RadDatePicker)item.FindControl(“radDatePickerTo”);

Read Full Post »

Too many people don’t realize that there are other options than <!– –> comments to annotate HTML. These comments are harmful because they are sent to the client and thus make your page heavier than it needs to be.

Replacing client comments with server comments.When doing ASP.NET, a simple drop-in replacement is server comments, which are delimited by <%– –%> instead of <!– –>. Those server comments are visible in your source code, but will never be rendered to the client.

Here’s a simple way to sanitize a web site. From Visual Studio, hit CTRL+H to bring the search and replace dialog.

Choose “Replace in Files” from the second menu on top of the dialog. Open the find options, check “use” and make sure “Regular expressions” are selected. Use “*.aspx;*.ascx;” as the file types to examine. Choose “Entire Solution” under “Look in”.

Here’s the expression to search for comments:


And here’s the replacement string:


I usually use the “Find Next” and “Replace” buttons rather than the more brutal “Replace All” in order to not apply the fix blindingly. Once this is done, I do a second manual pass of finds with the same expression to make sure I didn’t miss anything.

Actual Resource :


Read Full Post »

Older Posts »