jicama bite

share whatever knowledge that I might have

Get the Field Name from a Class Data

How to Get the list of fields from a class, let say “ProposalData”.
ProposalData contains public property Id, Title, and SubmissionDate. We will get those three property using System.Reflection member class called “PropertyInfo”. See the example below:

public List<string> GetFieldProposalDataData()
{
List<string>listField = new List<string>();
PropertyInfo[] propertyInfos;
propertyInfos = typeof(ProposalData).GetProperties();
foreach (PropertyInfo propertyInfo in propertyInfos)
{
listField.Add(propertyInfo.Name);
}
return listField;
}

Okay, may it helps

January 5, 2012 Posted by | Programming | , , , , | Leave a comment

Thread was being aborted

Such title above, is caused by Page Redirect inside try and catch methods.
That, could be solved by adding “false” parameter inside :

Response.Redirect(“Page.aspx”,false);

Okay, may it helps

January 5, 2012 Posted by | Programming | , , , | Leave a comment

Multiple database on Nhibernate

Multiple database is supported by Nhibernate.
Example below is using schema tag (bold) on hbm.xml file :

<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" auto-import="true" schema=”worktracking”>

Schema means = Database name
But, this method only work on the same server.

Okay, may it helps

January 5, 2012 Posted by | Database, Programming | , , , , | Leave a comment

Cookie Iframe Problem on IE

Applications that use IFrame to call content from another web page, will be slightly impaired if the browser is Internet Explorer (IE). As for other browsers like Mozilla will be running normally. This happens because IE does not accept variables, in the form of session & cookies from unrecognize third party . IE only recognize the cookie / session that already meet the W3C standard called Platform for Privacy Preferences (P3P).

The Following tips :

1. The simplest way: Open IE, select the option Tools – Internet Options. On the Privacy tab, change the level setting to Low. Close IE and reopen, then your application will run normally. But this  is inefficient way,  because they have to change the IE settings on all clients.

2. This method is also simple, is adding one line of code on pages that do create session / cookies.

PHP:

header(‘P3P:CP=”IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT”‘);

 

ASP.NET:

HttpContext.Current.Response.AddHeader(“p3p”,”CP=\”IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT\””);

The second is better, and no need to do the first.

Guaranteed your application will run properly.

Ok, may it helps

Thanks

September 27, 2011 Posted by | Programming | , , , , , , , , , | 1 Comment

“The web services enumeration components are not available”

For who met with the error “The web services enumeration components are not available. You need to reinstall Visual Studio to add web references to your application”,  when working with Web Service or Windows Communication Foundation, you can type the following

devenv / resetskippkgs

on Visual Studio 2005/2008 command prompt
Now you can continue your work without being haunted error message.

Ok, may it helps

Thanks

September 27, 2011 Posted by | Programming | , , , | Leave a comment

Setting “Execution Time Out”

If you find an error with the message “Execution Time Out”, was one reason is the connection to the database that is too long.

By default, a web server in the Timeout setting is 30 seconds max. Once there is a database connection that is more than 30 seconds, then the error message will be sent.

Then how do we want to enlarge this timeout, for example 60 seconds. The following piece of c# code themselves:

using (SqlConnection conn = new SqlConnection(“ConnectionString”))

{

conn.Open();

SqlCommand cmd = new SqlCommand(SpName, conn);

cmd.CommandType = CommandType.StoredProcedure;

cmd.CommandTimeout = 60; //add timeout here

SqlParameter[] sqlParameter = new SqlParameter[2];

sqlParameter[0] = new SqlParameter(“@MhsId”, SqlDbType.Char, 10);

sqlParameter[0].Direction = ParameterDirection.Input;

sqlParameter[0].Value = mhsId;

sqlParameter[1] = new SqlParameter(“@PriodId”, SqlDbType.Char, 25);

sqlParameter[1].Direction = ParameterDirection.Input;

sqlParameter[1].Value = periodId;

cmd.Parameters.AddRange(sqlParameter);

using (SqlDataReader sqlDataReader = cmd.ExecuteReader())

{

}

}

Ok, may it helps

Thanks

September 27, 2011 Posted by | Database, Programming | , , | Leave a comment

Setting “SessionTimeOut” on web config

There are two ways of setting the Session Time Out in asp.net:

1. Add value key in web config, and use it on your code

2. Use the settings that have been provided in the web config itself. Just open your webconfig file and insert these value :

<system.web>

<sessionState mode=”InProc”timeout=”60″/>

</system.web>

 

There is no need to add on your code anymore.

In this way, all the sessions that we’ve made will be automatically sets by value above.

Ok, may it helps

Thanks

September 27, 2011 Posted by | Programming | , , , , , | Leave a comment

Refresh Page Automatically

Sometimes a web site is required to refresh the page automatically. It aims to update the data or get the data automatically, to  be displayed in a web page.
Just Modif the “CONTENT” tag, by minute.
Add the following meta tag bg:

<META HTTP-EQUIV=”refresh” CONTENT=”15″>

Ok, may it helps

Thanks

September 27, 2011 Posted by | Programming | , , , , | Leave a comment

“Application” Variable Web Application

How do I create an “agent” who will be running automatically when a page in the web application is run? “Agent” runs only once a day, no more. In fact this web page is accessed by many people per day.
Here are some solutions:
1. Save the date  in the database. Weaknesses: would be too frequent connection to the database server, the server Will be busy …
2. Save the date  in the Application variable. Put this code into your default page :

if (!IsPostBack)
{
if (Application[“date”] != null)
{
if (Convert.ToDateTime(Application[“date”]) != DateTime.Today)
{
Application[“date”] = DateTime.Today;
//do something
}
}
else
{
Application[“movingdate”] = DateTime.Today;
//do something
}
}

Application variables are very similar to the Session. Session will run out if the web page was closed. Meanwhile, the Application would not run out even though the web page is closed. So in the Application, the values ​​will be stored on, except for Servers to die then it will return an empty / null.

Ok, may it helps

Thanks

August 25, 2011 Posted by | Programming | , , , , , , , , | Leave a comment

Customize FckEditor Toolbar

There are too much default toolbar on the FCKEditor, and sometimes is not necessarily required. Here’s the trick to remove the toolbar to FCKEditor. In fact we can set placement as well.

1. Open the File “fckconfig.js”. By default you will find the toolbar set FCKConfig.ToolbarSets [“Default”]. You can create your own set of example FCKConfig.ToolbarSets [“MySet”]. Then fill its value as you see fit.

2. Add attributes ToolbarSet = “MySet” on FCKEditor tag on your page.

 

Ok, may it helps,

Thanks

August 25, 2011 Posted by | Programming | , , , | Leave a comment