Monday, May 25, 2009

Running a SQL query to replace certain characters in a table

Let say,
You have a database that contains many characters and symbols. If you want to replace those , just run the following SQL query:

(Here, suppose a symbol ~! need to replace by - then your query will be:)

UPDATE table
SET ColumnName= replace(LTRIM(RTRIM(ColumnName)), '~!', '-')

Happy Programming!:)

Sunday, May 10, 2009

Master page with Searchbox

Consider a master page with a search functionality and other number of content pages derived from that master page, so that searchbox appears in all pages. If you want to display a search results in Search.aspx page no matter where you are( in other content pages),add this code:

In MasterPage.cs:
Protected void search_button_Click(object sender, EventArgs e)
{
//redirect textbox's value to search.aspx page
Response.Redirect(@"~/search.aspx?q=" + Server.UrlEncode(txtSearch.Text));
}

In Search.aspx.cs:
protected void Page_Load(object sender, EventArgs e)
{
//read the master page's redirected value
string str = Request.QueryString[@"q"];
}

--Happy Coding