Feeds:
Posts
Comments

Archive for the ‘.Net’ Category

///<summary>

/// The main entry point for the application.

///</summary>

[STAThread]

staticvoid Main()

{

//AddGlobalHandlers();

Application.EnableVisualStyles();

Application.SetCompatibleTextRenderingDefault(false);

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

Application.ThreadException += newThreadExceptionEventHandler(Application_ThreadException);

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

Application.Run(newMainForm());

}

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);

}

Advertisements

Read Full Post »

 

        private void txtTest_TextChanged(object sender, EventArgs e)

 

        {

 

            common_functions.SetAutoHightforTextBox(sender);          

 

        }

 

 

 

 

 

        /// <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”.

e.g.

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)
AS BEGIN
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
END

Called above UDF in C#.Net :

public string GetGlobalSiteTypeName(string SiteTypeName, string CampID)
{
string retValue = “”;
try
{
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;
cmdGetGlobalSiteType.Parameters.Add(prmSiteTypeName);
cmdGetGlobalSiteType.ExecuteNonQuery();
if (Convert.ToString(prmSiteTypeName.Value) != “”)
retValue = Convert.ToString(prmSiteTypeName.Value);

}
catch (Exception)
{

throw;
}
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)
{
try
{
RadDatePicker radDatePickerFrom = (RadDatePicker)sender;
GridDataItem item = (GridDataItem)radDatePickerFrom.NamingContainer;
RadDatePicker radDatePickerTo = (RadDatePicker)item.FindControl(“radDatePickerTo”);

Read Full Post »

e.g

int iRowIndexToProcess = 0;

const int constStartIndex = iRowIndexToProcess;

Ans : No !

Read Full Post »

Older Posts »