Follow by Email

Using of update panel (UpdatePanel) of ajax in

In  this tutorial i will explain how can we use UpdatPanel control which you can find in the section Ajax Extensions in the Toolbox...
UpdatPanel is used if you want to do partial post back i.e. if we want to post back only some part of the page & not whole page.
For example take a example of taking two numbers in the text box & showing it in the third text box on button click. As it is very easy you can create this of your own. create this all controls in the UpdatPanel.
Remember to put ScriptManager Control before the UpdatPanelas it is required to run any java script of Ajax.
Now take one more text box out side the UpdatPanel just to ensure that partial post back is occuring.
Your code will look something like this....

<div style="background-color:Gray;width:400px;padding:10px 0px 10px 10px;">
  <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
       First Number : <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
       <br />
       Second Number : <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
       <br />
       <asp:Button ID="Button1" runat="server" Text="Add" onclick="Button1_Click" />
       <br />
       Addition :<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
<div style="margin-top:50px;background-color:Gray;width:400px;padding:10px 0px 10px 10px;">
  <asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
& button click code would be something like this ... 
    protected void Button1_Click(object sender, EventArgs e)
        int a = Convert.ToInt32(TextBox1.Text);
        int b = Convert.ToInt32(TextBox2.Text);
        TextBox3.Text = (a + b).ToString();
Now run your application.....
When page opens ...write something in the textbox which is outside the update panel ....
& then put some numbers in the first & second text box & click on add .....
Post back will happen only for that portion & addition will come on the third textbox .... 
But you can see that text written in the last textbox is as it is as only controls inside had a post back & not whole page...
UpdatePanel has two properties UpdateMode &  ChildrenAsTriggers .
It has two values
1)Always: It indicates that content of the each control in side that UpdatePanel should be updated on each post back which originates from the page.
2)Conditional:  It indicates that control should be updated only on the post back of specific controls.

 When this property is set to true then any updates triggered by the nested UpdatePanel will also trigger an update to the parent UpdatePanel.

Lucene Search for multilingual websites or separating searches for the nodes

I searched on internet but dident got the proper solution for using Lucene Search for multilingual websites , so i decided to make this tutorial to help others...
In this tutorial i will show you that how can we separate searches for multilingual websites using lucene search in umbraco.
lets assume that our website is in 2 languages i.e. in english & in danish
Then we will have our nodes in umbraco some thing like this...
 EN node is home page of english website & DK node is home page of danish webiste....

to make searches separate we need to create 2 separate index i.e. one index for each language.
Here we will create indexes in a way that they will index each language home page node & its all childs.
We can do it some thing like this....

<IndexSet SetName="ENIndexSet" IndexPath="/App_Data/ExamineIndexes/EN/" 
    <IndexAttributeFields>   <!--1165 is id of the "EN" node -->
       <add Name="id" />
      <add Name="nodeName" />
      <add Name="updateDate" />
      <add Name="writerName" />
      <add Name="path" />
      <add Name="nodeTypeAlias" />
      <add Name="parentID" />
    <IndexUserFields />
    <IncludeNodeTypes />
    <ExcludeNodeTypes />
  <IndexSet SetName="DKIndexSet" IndexPath="/App_Data/ExamineIndexes/DK/" 
    <IndexAttributeFields> <!--1624 is id of the "DK" node -->
      <add Name="id" />
      <add Name="nodeName" />
      <add Name="updateDate" />
      <add Name="writerName" />
      <add Name="path" />
      <add Name="nodeTypeAlias" />
      <add Name="parentID" />
    <IndexUserFields />
    <IncludeNodeTypes />
    <ExcludeNodeTypes />
By doing like this what will happen is that indexset named ENIndexSet will only index the "EN" node & its all child nodes &  DKIndexSet will only index the "DK" node & its all child nodes.

also we need to create providers & searcher  ...its is like this ....separate providers & searchers for each index..
<add name="ENIndexer" 
type="UmbracoExamine.UmbracoMemberIndexer, UmbracoExamine"
analyzer="Lucene.Net.Analysis.Standard.StandardAnalyzer, Lucene.Net"/>
<add name="DKIndexer" 
type="UmbracoExamine.UmbracoMemberIndexer, UmbracoExamine"
analyzer="Lucene.Net.Analysis.Standard.StandardAnalyzer, Lucene.Net"/>

<add name="ENSearcher"  
type="UmbracoExamine.UmbracoExamineSearcher, UmbracoExamine" 
analyzer="Lucene.Net.Analysis.Standard.StandardAnalyzer, Lucene.Net"  
<add name="DKSearcher" 
type="UmbracoExamine.UmbracoExamineSearcher, UmbracoExamine"  
analyzer="Lucene.Net.Analysis.Standard.StandardAnalyzer, Lucene.Net" 

 Now we need to create two user controls for each language for taking search words from users ...
on that page load of the user control you can call there corresponding search result  page .
The search result  page will call the xslt macro which will perform the operation of searching ....
the xslt will be something like this ....

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [
  <!ENTITY nbsp "&#x00A0;">
  exclude-result-prefixes="msxml umbraco.examine umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ">

  <xsl:output method="xml" omit-xml-declaration="yes"/>

  <xsl:param name="currentPage"/>

  <!-- Get the search term from the query string-->
  <xsl:variable name="searchTerm" select="umbraco.library:RequestQueryString('s')" />

<!-- where "s" is the querystring passed from the user control while redirecting to the search page -->

  <xsl:template match="/">

    <!-- Check if there's a search term to search on-->
    <xsl:if test="string-length($searchTerm) > 0">

      <!-- Get the search results from examine -->
      <!--************************ THIS IS WHERE THE MAGIC HAPPENS *****************************-->
 <xsl:variable name="results" select="umbraco.examine:SearchContentOnly($searchTerm,true,'ENSearcher')"/>

      <!--************************ END OF MAGIC ************************************************-->
       &nbsp;&nbsp;&nbsp;&nbsp; Search text:&nbsp;<b>
            <xsl:value-of select="$searchTerm"/>
            <xsl:value-of select="count($results//node)"/>

      <xsl:if test="count($results//node) > 0">

        <!-- there is a result, so show them in the order of best score -->

          <xsl:for-each select="$results//node">
            <xsl:sort select="number(@score)" order="descending"/>


              <!-- add alternating colors -->
<!--              <xsl:choose>
                <xsl:when test="position() mod 2 ">
                  <xsl:attribute name="class">secondary-a-5</xsl:attribute>
                  <xsl:attribute name="class">secondary-b-4</xsl:attribute>
              </xsl:choose>  -->

              <!-- Get the URL -->
              <xsl:variable name="url" select="concat('http://', umbraco.library:RequestServerVariables('SERVER_NAME') , ':' , umbraco.library:RequestServerVariables('SERVER_PORT') ,umbraco.library:NiceUrl(./data[@alias='id']))" />

              <!-- Create the search result line item-->
      <!--        <a href="{$url}">
                <span class="title">
                  <xsl:value-of select="./data[@alias='nodeName']"/>
                <span class="link">
                  <xsl:value-of select="$url"/>
                <span class="score">
                  <xsl:value-of select="./@score"/>
              </a> -->
                <div id="searchTitle"><a href="{$url}"><xsl:value-of select="./data[@alias='nodeName']"/></a> </div> <div id="searchTime"> <!-- <xsl:value-of select="./@score"/> --> </div>
              <xsl:value-of select="umbraco.library:TruncateString(./data[@alias='content'], 360,'...')" disable-output-escaping="yes"/>
              <!--<xsl:value-of select = "./data[@alias='content']"/> -->
              <div id="searchLink">
                <a href="{$url}"><xsl:value-of select="$url"/></a>



This is the xslt to search for the words in the english webiste.....

To create xslt for danish site you just need to change  ENSearcher  to DKSearcher  which is the name of the searcher.

Like this we can separate the searches using Lucene Search for multilingual websites.

For any doughs & suggestions do comments here  .....

Setting custom error page for umbraco website

its very easy to set the custom error page for the website ....
1) first create the error page which you want to show...
2) Then go to umbracoSettings.config which is inside config folder .
3) You will find this tag in that file...

      <!-- the id of the page that should be shown if the page is not found -->
      <!--        <errorPage culture="default">1</errorPage>-->
      <!--        <errorPage culture="en-US">200</errorPage>-->

In this inside error404 write the ID of your created custome error page.

Its done when error comes ..your page will be shown ....