Follow by Email

Applying Enter as default key for the textbox

In this tutorial i will show you how to apply some button as default key for the textbox on clicking the enter.

Take one textbox & take one button & go to the source of the code....

It will look something like this....

<asp:TextBox ID="TextBox2" runat="server">asp:TextBox>
<asp:Button ID="Button1"runat="server" Text="Button" />

Now to make Button1 as default key for textbox on enter we ndde to add both textbox & button in the
panel like this...

<asp:Panel ID="Panel1" runat="server">
<asp:TextBox ID="TextBox2" runat="server">asp:TextBox>
asp:Button ID="Button1"runat="server" Text="Button" />

Now we have to add one property to panel which is DefaultButton="Button1"

After adding this your code will look something like this...

<asp:Panel ID="Panel1" runat="server" DefaultButton="Button1">
asp:TextBox ID="TextBox2" runat="server">asp:TextBox>
asp:Button ID="Button1"runat="server" Text="Button" />

this make Button1 as default key for the panel & on clicking "Enter" event of
button will be raised.

On click default text of text box vanishes & on clicking out side some where default text appers in text box

In this tutorial i will show how we can vanish default text in textbox on click & appers ones we can out side somewhere like happens in search boxs of the many professional websites.

For this we just have to add two events to the text box.

Take one text box & go to the source of the text box.
code of textbox will look something like this....
 <asp:TextBox ID="TextBox1" runat="server">asp:TextBox>

We just have to add this two thing to text box & it will work as i said above....

onfocus="if(this.value =='SEARCH')this.value='';"

where "SEARCH" is default text of the textbox.
after adding this code of text box will look something like this....

<asp:TextBox ID="searchTextDown" runat="server"  
="if(this.value =='SEARCH')this.value='';"

Lucene Search in Umbraco searches for only lower case words or Lucene search is case sensitive in umbraco

From few days i was working on lucene search in umbraco. I did everything properly ie. copied latest dll files, did indexing , made user control for search but still it was not working fine .

After searching for about a day i found that lucene search by default converts the "search word" in to lower case & then searches for the word in the website.Due to this if i have same word with upper case in my website then it will not be filtered & shown in search result.

The solution is very much simple for this , just we have to change "analyzer" attribute in the
ExamineSettings.config file which will be in config folder of the umbraco website.

you will find that your indexer & Searcher will be having attribute "analyzer" something like this...
analyzer="Lucene.Net.Analysis.WhitespaceAnalyzer, Lucene.Net" 
Just you have to change analyzer to this....
analyzer="Lucene.Net.Analysis.Standard.StandardAnalyzer, Lucene.Net" 
save the file & then publish your all nodes ...
try searching with uppercase after this .... it will work the way you want ....

Hope it Helps ......

How to Read xml file using Xpath in C#

Here i will show you how to read the xml file using Xpath in the C#
Here is the XML file which i have used...

< ? xml version="1.0" encoding="UTF-8"?>
< projects>
< project id = "BP001">
< name>Banking Project
< / project>
< project id = "TP001">
< name>Telecommunication Project
< / project>
< project id = "PP001">
< name>Portal Project
< / project>
< / projects>
(please remove the spaces from above XML File)

I have used simple Console Application Which reads this XML File & stores data in the list ...

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.XPath;
using System.Xml;

namespace ConsoleExamples
class readXMLusingXPath
static void Main(string[] args)
readxml read = new readxml();

class readxml
private XmlDocument ReadDoc = new XmlDocument();
string nodename = string.Empty;
static XmlNode node;
List strnodes = new List();
public void xmlread()
node = ReadDoc.SelectSingleNode("projects");
public void loadnodes(XmlNode nd)
XmlNodeList nodelist = nd.SelectNodes("project");
foreach (XmlNode node1 in nodelist)
if (node1.ToString() != null)
strnodes.Add(node1.Name.ToString() + " id = " + node1.Attributes.GetNamedItem("id").Value);
XmlNode node2 = node1.SelectSingleNode("name");
if (node2.ToString() != null)
strnodes.Add(node2.Name.ToString() + " = " + node1.SelectSingleNode("name").InnerText);

Hope it helps ....