her er "hoved siden" hvor jeg kalder funktionen fra: 
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Configuration;
using System.Data.SqlTypes;
using System.Web.Services; 
namespace WebApplication1
{                
    public class WebForm1 : System.Web.UI.Page
    {
        public System.Web.UI.WebControls.Label DN_Application_Name; 
        public System.Web.UI.WebControls.Label DN_Application_Name_Page; 
        public System.Web.UI.WebControls.Label DN_Application_Name_Index;
        protected System.Web.UI.WebControls.HyperLink HyperLink1;
        protected System.Web.UI.WebControls.CheckBox DocTypeTemplatesChek;
        protected System.Web.UI.WebControls.CheckBox DocTypeExamplesChek;
        protected System.Web.UI.WebControls.CheckBox DocTypePresentationsChek;
        protected System.Web.UI.WebControls.CheckBox DocTypeTrainingChek;
        protected System.Web.UI.WebControls.CheckBox DocTypeAllChek;
        protected System.Web.UI.WebControls.TextBox SearchFor;
        protected System.Web.UI.WebControls.DropDownList FileTypeValg;
        protected System.Web.UI.WebControls.LinkButton LinkButton1;
        protected System.Web.UI.WebControls.Label Label1;
        protected System.Web.UI.WebControls.Label Label2;
        protected System.Web.UI.WebControls.Button SubmitSearch;
        protected System.Web.UI.WebControls.ImageButton ImageButton1;
        protected System.Web.UI.WebControls.ImageButton ImageButton2;
        protected System.Web.UI.WebControls.ImageButton ImageButton4;
        protected System.Web.UI.WebControls.ImageButton ImageButton5;
        protected System.Web.UI.WebControls.ImageButton ImageButton7;
        protected System.Web.UI.WebControls.ImageButton ImageButton3;
        protected System.Web.UI.WebControls.ImageButton ImageButton6;
        protected System.Web.UI.WebControls.ImageButton ImageButton8;
        protected System.Web.UI.WebControls.ImageButton ImageButton9;
        protected System.Web.UI.WebControls.ImageButton ImageButton10;
        protected System.Web.UI.WebControls.ImageButton ImageButton11;
        protected System.Web.UI.WebControls.ImageButton ImageButton12;
        protected System.Web.UI.WebControls.ImageButton ImageButton13;
        protected System.Web.UI.WebControls.ImageButton ImageButton14;
        protected System.Web.UI.HtmlControls.HtmlGenericControl DIAGRAMstartside;
        protected System.Web.UI.WebControls.ListBox ListBox1;    
        private void Page_Load(object sender, System.EventArgs e)
        {
            //  code to initialize the page here
            DN_Application_Name = new Label(); 
            DN_Application_Name_Page = new Label(); 
            DN_Application_Name_Index = new Label(); 
            DN_Application_Name.Text = "PRG Pages for DPP "; 
            DN_Application_Name_Index.Text = "";            
            SetDefaultButton(this.Page, SearchFor, SubmitSearch);            
            if(!IsPostBack)
            {
                FillFileList();
            }        
        }
        #region Web Form Designer generated code
        override protected void OnInit(EventArgs e)
        {
            // This call is required by the ASP.NET Web Form Designer.            
            InitializeComponent();
            base.OnInit(e);
        }        
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {    
            this.ListBox1.SelectedIndexChanged += new System.EventHandler(this.ListBox1_SelectedIndexChanged);
            this.SubmitSearch.Click += new System.EventHandler(this.SubmitSearch_Click);
            this.DocTypePresentationsChek.CheckedChanged += new System.EventHandler(this.DocTypePresentationsChek_CheckedChanged);
            this.DocTypeTemplatesChek.CheckedChanged += new System.EventHandler(this.DocTypeTemplatesChek_CheckedChanged);
            this.DocTypeExamplesChek.CheckedChanged += new System.EventHandler(this.DocTypeExamplesChek_CheckedChanged);
            this.DocTypeTrainingChek.CheckedChanged += new System.EventHandler(this.DocTypeTrainingChek_CheckedChanged);
            this.DocTypeAllChek.CheckedChanged += new System.EventHandler(this.DocTypeAllChek_CheckedChanged);
            this.LinkButton1.Click += new System.EventHandler(this.LinkButton1_Click);
            this.ImageButton1.Click += new System.Web.UI.ImageClickEventHandler(this.ImageButton1_Click);
            this.ImageButton5.Click += new System.Web.UI.ImageClickEventHandler(this.ImageButton5_Click);
            this.Load += new System.EventHandler(this.Page_Load);
        }
        #endregion        
        // Set default Button
        public void SetDefaultButton(Page page, TextBox textControl, Button defaultButton)
        {
            string theScript = @"
<SCRIPT language=""javascript"">
<!--
function fnTrapKD(btn, event){
 if (document.all){
  if (event.keyCode == 13){
   event.returnValue=false;
   event.cancel = true;
   btn.click();
  }
 }
 else if (document.getElementById){
  if (event.which == 13){
   event.returnValue=false;
   event.cancel = true;
   btn.click();
  }
 }
 else if(document.layers){
  if(event.which == 13){
   event.returnValue=false;
   event.cancel = true;
   btn.click();
  }
 }
}
// -->
</SCRIPT>"; 
            Page.RegisterStartupScript("ForceDefaultToScript", theScript);
            textControl.Attributes.Add("onkeydown", "fnTrapKD(" + defaultButton.ClientID + ",event)");
        }
        // Fill the filelist with files from the database
        private void FillFileList()
        {
            string SQLconStr = ConfigurationSettings.AppSettings["SQLcon"];
            SqlConnection DB_Connection = new SqlConnection(SQLconStr);
            SqlDataAdapter StepAdapter = new SqlDataAdapter("SELECT * FROM DPP_data ORDER BY filename asc", DB_Connection);
            DataSet FileList = new DataSet();
            StepAdapter.Fill(FileList, "FileListSet");            
            ListBox1.DataSource = FileList;
            ListBox1.DataMember = "FileListSet";
            ListBox1.DataTextField = "filename";
            ListBox1.DataValueField = "path";
            ListBox1.DataBind();        
            Label2.Text = "";
            Label1.Text = "Showing All Files";
        }                
        // Make link to selected file from filelist
        private void ListBox1_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            string ValgtEnhed = "";
            string ValgtPath = "";
            ValgtEnhed = ListBox1.SelectedItem.Text.ToString();
            ValgtPath = ListBox1.SelectedItem.Value.ToString();
            HyperLink1.NavigateUrl = "
file://fp02-f01\\CF01-GRP\\Projekter\\DPP\\PRG\\Attachements\\Active attachements\\"+ ValgtPath + ValgtEnhed;
        }
        // Fill the filelist with search resaults (search engine)
        private void SubmitSearch_Click(object sender, System.EventArgs e)
        {
            WebApplication1.search.search2(FileTypeValg, SearchFor, ListBox1, Label1, Label2, FileList, System.Data.SqlClient.SqlData, DocTypeAllChek, DocTypeExamplesChek, DocTypePresentationsChek, DocTypeTemplatesChek, DocTypeTrainingChek);
        }        
        // Checks buttons, changes the way the searchengine works
        private void DocTypeAllChek_CheckedChanged(object sender, System.EventArgs e)
        {
            DocTypeExamplesChek.Checked = false;
            DocTypePresentationsChek.Checked = false;
            DocTypeTemplatesChek.Checked = false;
            DocTypeTrainingChek.Checked = false;           
        }
        private void DocTypeTrainingChek_CheckedChanged(object sender, System.EventArgs e)
        {
            DocTypeAllChek.Checked = false;    
        }
        private void DocTypeTemplatesChek_CheckedChanged(object sender, System.EventArgs e)
        {
            DocTypeAllChek.Checked = false;
        }
        private void DocTypePresentationsChek_CheckedChanged(object sender, System.EventArgs e)
        {
            DocTypeAllChek.Checked = false;
        }
        private void DocTypeExamplesChek_CheckedChanged(object sender, System.EventArgs e)
        {
            DocTypeAllChek.Checked = false;            
        }
        // Button to show all files again 
        private void LinkButton1_Click(object sender, System.EventArgs e)
        {
            FillFileList();
        }
        private void ImageButton3_Click(object sender, System.Web.UI.ImageClickEventArgs e)
        {        
        }
        private void ImageButton5_Click(object sender, System.Web.UI.ImageClickEventArgs e)
        {        
        }
        private void ImageButton1_Click(object sender, System.Web.UI.ImageClickEventArgs e)
        {
        }
    }
}