Thursday, September 27, 2007

Registering a client script on a Sharepoint Custom Page

 

This a is a self memory post, because i know i ll need it again.

In this case i am creating a function to load a Flash Movie

Of course it is part of a ASP.Net Page developed with Visual Studio 2003

 

private void Page_PreRender(object sender, System.EventArgs e)
{

        scriptString += "function changeMovie(){";

        scriptString += "var d=document;";           

        if (Page.IsPostBack)
        {                            
            scriptString += "myflash='" + lblFlashnameValue.Value  + "&Hoja="+  lblIdHojaValue.Value +"';" ;
        }
        else
        {
            //First Time
            scriptString += "mypath='"  + Request.QueryString["TMCOrigen"]  +  "/_layouts/pages/';";
            scriptString += "mypathXML='"  + Request.QueryString["TMCOrigen"]  +  "/_layouts/pages/';";                   
            scriptString += "myflash=mypath+'tree20070921R.swf?SharepointTree='+ mypathXML + " + "'"+"tree99.xml"+"'" +";";           

        }

        scriptString += "d.all('tree20070921R').LoadMovie(0, myflash);";
        scriptString += "d.all.lblFlashnameValue.value =   myflash ;";           
        scriptString += "}";
        scriptString += "</script>";
        Page.RegisterClientScriptBlock("clientScript", scriptString);
}

Wednesday, September 19, 2007

Creating or adding an attribute (xmlAttribute) on a node in c# and Visual Studio 2003

 

 

 

//Add attribute id2
XmlDocument xDocId2 = new XmlDocument();                               
xDocId2.Load (tmpFilename);           
foreach (XmlNode unNodo in xDocId2.DocumentElement.GetElementsByTagName("nodo") )
{
    XmlAttribute nAttr;
    nAttr =  xDocId2.CreateAttribute ("id2");   
    nAttr.Value= unNodo.Attributes["id"].Value     ;
    unNodo.Attributes.Append( nAttr);
}
xDocId2.Save(tmpFilename);

Tuesday, September 04, 2007

Enabling Wildcard Search in Sharepoint 2003

 

 

This walkthrough will guide  you how to enable wild search using SPS, you need to do the following:

  1. Export the search result web part.
  2. Customize the DWP file, add query to enable the wild search criteria
  3. Import the web part back to SPS and drop it within search page area.

Here are the details:

  1. Go to your search page. By default, you won’t be able to modify it, go to this link to enable the shared mode
    http://your_server/search.aspx?mode=edit&view=shared
  2. Modify the Shared Page, and export the search result Web Part (just save it in your desktop, by default it has *.dwp extension)
  3. The Webpart file (DWP) is basically XML File, so you can open it using Notepad. Go find this section : “QueryTemplateWherePart”
  4. Add the following code in the END of the section to enable the wide search : OR CONTAINS("urn:schemas-microsoft-com:sharepoint:portal:profile:PreferredName", '"%__keywordinput__%"') RANK BY COERCION(multiply, 0.01)
    OR CONTAINS(#WeightedProps, '"%__keywordinput__%"')
  5. Save the file, go back to your sharepoint modify page – Add Web Parts – Import
  6. Drop your modified search result web part to your search page. And that’s all, hope this help…

 

Pros:

You ll be able to use the asterisc at the end of a word so as to make a search like Pro*, where you ll get results for word as project, prototype,etc

Cons:

User will not be allowed to save their search alerts and ll get this error, "An error has occurred on the server" . You can find info here http://support.microsoft.com/kb/920823/en-us