+1-888-365-2779
Try Now
More in this section

Forums / General Discussions / Can I integrate an existing web application with Sitefinity?

Can I integrate an existing web application with Sitefinity?

8 posts, 0 answered
  1. Jome Akpoduado
    Jome Akpoduado avatar
    16 posts
    Registered:
    07 Jan 2010
    11 Jan 2010
    Link to this post
    Hello,
    pardon me if this has been answered already but I recently got interested in this product and it looks like its what I will need. I have a existing database web application (still under development though) running on SQL Server. It has two master pages, several aspx pages (including data entry forms) tied to the master pages, custom web controls, etc.
    Can I successfully integrate this application with as little pain as possible. For example, if I wished for my pages to use the provided templates in Sitefinity, how would I go about this?
    How do I reference my existing database without "harming" the database the CMS has already setup?

    Thanks guys.
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    11 Jan 2010
    Link to this post
    Hi Jome Akpoduado,

    There are two options that I could come up.

    1. Use your current (not Sitefinity website) pages as ExternalPages in Sitefinity. Note that this does not allow you to drag/drop controls, setting themes etc.

    2. Migrate the pages to Sitefinity using our API. You may find the following link useful - Pages Overview

    If most of the logic in your current website is represented by user/custom controls you can easily migrate the controls and your pages.

    Let us know if there are any further questions.

    Best wishes,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. Jome Akpoduado
    Jome Akpoduado avatar
    16 posts
    Registered:
    07 Jan 2010
    12 Jan 2010
    Link to this post
    Hey Ivan,
    Thanks for the reply... I read through the docs (although in  hurry, I must confess) to understand how to make this work but I'm a little stumped as to the how...
    I've a lot of code-behind files (C#) and I dont see this at work in sitefinity.
    here's a sample of a page I have with its associated code behind.
    <%@ Page Title="" Language="C#" MasterPageFile="~/cedweb.master" AutoEventWireup="true" 
        CodeFile="churches.aspx.cs" Inherits="admin_churches" %> 
     
    <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server"
    </asp:Content> 
    <asp:Content ID="Content2" ContentPlaceHolderID="SidebarContent" runat="Server"
         
    </asp:Content> 
    <asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="Server"
        <asp:Label ID="lblPageTitle" runat="server" Text="Church Setup" CssClass="pagetitle"></asp:Label> 
        <hr /> 
        <asp:Label ID="lblChurchListing" runat="server" Text="List of Churches in Kwazulu Natal" 
            CssClass="controlelements"></asp:Label> 
            <asp:GridView ID="grdChurchListing" runat="server" 
                CssClass="controlpanels" AutoGenerateColumns="False"  
            OnSelectedIndexChanged="grdChurchListing_SelectedIndexChanged"  
            DataKeyNames="ChurchID"
            <Columns> 
                <asp:CommandField ButtonType="Button" ShowSelectButton="True" /> 
                <asp:BoundField DataField="ChurchID" HeaderText="Church ID" Visible="False" /> 
                <asp:BoundField DataField="ChurchName" HeaderText="Church Name" /> 
                <asp:BoundField DataField="ChurchAddress" HeaderText="Church Address" /> 
                <asp:BoundField DataField="PhoneNumber" HeaderText="Contact Number" /> 
                <asp:BoundField DataField="EmailAddress" HeaderText="Email Address" /> 
                <asp:BoundField DataField="Pastor" HeaderText="Pastor / Coordinator" /> 
            </Columns> 
        </asp:GridView> 
        <asp:Button ID="btnAddChurch" Text="Add a Church" runat="server" Visible="true"  
            onclick="btnAddChurch_Click" /> 
        <asp:Panel ID="pnlChurchList" runat="server" GroupingText="Details" Visible="false" 
            Width="600"
            <asp:Label ID="lblChurchName" runat="server" CssClass="controlelements" Text="Name of Church:" 
                Width="120"></asp:Label> 
            <asp:TextBox ID="txtChurchName" runat="server" Text="" Width="200"></asp:TextBox><br /> 
            <asp:Label ID="lblChurchAddress" runat="server" CssClass="controlelements" Text="Church Address:" 
                Width="120"></asp:Label> 
            <asp:TextBox ID="txtChurchAddress" runat="server" Text="" CssClass="controlelements" 
                Width="200" TextMode="MultiLine" Rows="4"></asp:TextBox><br /> 
            <asp:Label ID="lblChurchNumber" runat="server" CssClass="controlelements" Text="Phone Number:" 
                Width="120"></asp:Label> 
            <asp:TextBox ID="txtChurchNumber" runat="server" Text="" Width="200"></asp:TextBox><br /> 
            <asp:Label ID="lblEmailAddress" runat="server" CssClass="controlelements" Text="Email Address:" 
                Width="120"></asp:Label> 
            <asp:TextBox ID="txtEmailAddress" runat="server" Text="" Width="200"></asp:TextBox><br /> 
            <asp:Label ID="lblPastor" runat="server" CssClass="controlelements" Text="Pastor/Coordinator:" 
                Width="120"></asp:Label> 
            <asp:TextBox ID="txtPastor" runat="server" Text="" Width="200"></asp:TextBox><br /> 
            <asp:Button ID="btnSave" runat="server" Text="Save Details" Width="120"  
                onclick="btnSave_Click" /> 
                <asp:Button ID="btnDelete" runat="server" Text="Delete" Width="120"  
                onclick="btnDelete_Click" /> 
            <asp:Button ID="btnCancel" runat="server" Text="Cancel" Width="120"  
                onclick="btnCancel_Click" /> 
        </asp:Panel> 
    </asp:Content> 

    using System; 
    using System.Collections.Generic; 
    using System.Linq; 
    using System.Web; 
    using System.Web.UI; 
    using System.Web.UI.WebControls; 
    using cedurban; 
     
    public partial class admin_churches : System.Web.UI.Page 
        protected void Page_Load(object sender, EventArgs e) 
        { 
            LoadGrid(); 
        } 
     
        private void LoadGrid() 
        { 
            ceHelper.DataBindGrid("Churches", ref grdChurchListing); 
     
        } 
        protected void grdChurchListing_SelectedIndexChanged(object sender, EventArgs e) 
        { 
            int index = grdChurchListing.SelectedIndex; 
            txtChurchName.Text = grdChurchListing.Rows[index].Cells[2].Text; 
            txtChurchAddress.Text = grdChurchListing.Rows[index].Cells[3].Text; 
            txtChurchNumber.Text = grdChurchListing.Rows[index].Cells[4].Text; 
            txtEmailAddress.Text = grdChurchListing.Rows[index].Cells[5].Text; 
            txtPastor.Text = grdChurchListing.Rows[index].Cells[6].Text; 
     
            pnlChurchList.Visible = true
            btnAddChurch.Visible = false
            btnSave.Text = "Update Details"
        } 
        protected void btnCancel_Click(object sender, EventArgs e) 
        { 
            pnlChurchList.Visible = false
            btnAddChurch.Visible = true
        } 
        protected void btnAddChurch_Click(object sender, EventArgs e) 
        { 
            ClearFields(); 
     
            btnAddChurch.Visible = false
            pnlChurchList.Visible = true
        } 
     
        private void ClearFields() 
        { 
            ceHelper.ClearTextBoxes(this); 
        } 
     
        protected void btnSave_Click(object sender, EventArgs e) 
        { 
            //Run validation code here 
     
            //End validation 
     
            //Save data 
            databankDataContext db = new databankDataContext(); 
            if (btnSave.Text == "Update Details") 
            { 
                Church updateChurch = db.Churches.Single(p => p.ChurchID == Convert.ToInt32(grdChurchListing.SelectedDataKey["ChurchID"])); 
                updateChurch.ChurchAddress = txtChurchAddress.Text; 
                updateChurch.ChurchName = txtChurchName.Text; 
                updateChurch.Pastor = txtPastor.Text; 
                updateChurch.EmailAddress = txtEmailAddress.Text; 
                updateChurch.PhoneNumber = txtChurchNumber.Text; 
            } 
            else 
            { 
                Church newnewChurch = new Church(); 
                newChurch.ChurchName = txtChurchName.Text; 
                newChurch.EmailAddress = txtEmailAddress.Text; 
                newChurch.ChurchAddress = txtChurchAddress.Text; 
                newChurch.Pastor = txtPastor.Text; 
                newChurch.PhoneNumber = txtChurchNumber.Text; 
     
                db.Churches.InsertOnSubmit(newChurch); 
            } 
            db.SubmitChanges(); 
            ClearFields(); 
            btnSave.Text = "Save Details"
            pnlChurchList.Visible = false
            btnAddChurch.Visible = true
            LoadGrid(); 
     
             
        } 
        protected void btnDelete_Click(object sender, EventArgs e) 
        { 
            int index = grdChurchListing.SelectedIndex; 
            int churchID = Convert.ToInt32(grdChurchListing.SelectedDataKey["ChurchID"].ToString()); 
     
            databankDataContext db = new databankDataContext(); 
            Church deleteChurch = db.Churches.Single(p => p.ChurchID == churchID); 
            db.Churches.DeleteOnSubmit(deleteChurch); 
            db.SubmitChanges(); 
            ClearFields(); 
            pnlChurchList.Visible = false
            btnAddChurch.Visible = true
            LoadGrid(); 
        } 
     


    How would I go about converting this to a format required by sitefinity, retaining the logic? I hope this is not too much trouble.

    Thanks.
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    12 Jan 2010
    Link to this post
    Hi Jome Akpoduado,

    Creating masterpage files is the same as in each ASP.NET application, so you should not have problem with this. Once you create cedweb.master you have to go to Sitefinity's backend and create a page through its interface. Then choose cedweb as a template for your page and you will see the tree ContentPlaceHolders you have ( the same applies for nested masterpages). Then move the logic from the third holder to a user control and just drop this control on this page.

    the user control should look like as shown below

    sample code

    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="Test.ascx.cs" Inherits="CustomControls_Test" %>
     
     
     <asp:Label ID="lblPageTitle" runat="server" Text="Church Setup" CssClass="pagetitle"></asp:Label>
        <hr />
        <asp:Label ID="lblChurchListing" runat="server" Text="List of Churches in Kwazulu Natal"
            CssClass="controlelements"></asp:Label>
            <asp:GridView ID="grdChurchListing" runat="server"
                CssClass="controlpanels" AutoGenerateColumns="False" 
            OnSelectedIndexChanged="grdChurchListing_SelectedIndexChanged" 
            DataKeyNames="ChurchID">
            <Columns>
                <asp:CommandField ButtonType="Button" ShowSelectButton="True" />
                <asp:BoundField DataField="ChurchID" HeaderText="Church ID" Visible="False" />
                <asp:BoundField DataField="ChurchName" HeaderText="Church Name" />
                <asp:BoundField DataField="ChurchAddress" HeaderText="Church Address" />
                <asp:BoundField DataField="PhoneNumber" HeaderText="Contact Number" />
                <asp:BoundField DataField="EmailAddress" HeaderText="Email Address" />
                <asp:BoundField DataField="Pastor" HeaderText="Pastor / Coordinator" />
            </Columns>
        </asp:GridView>
        <asp:Button ID="btnAddChurch" Text="Add a Church" runat="server" Visible="true" 
            onclick="btnAddChurch_Click" />
        <asp:Panel ID="pnlChurchList" runat="server" GroupingText="Details" Visible="false"
            Width="600">
            <asp:Label ID="lblChurchName" runat="server" CssClass="controlelements" Text="Name of Church:"
                Width="120"></asp:Label>
            <asp:TextBox ID="txtChurchName" runat="server" Text="" Width="200"></asp:TextBox><br />
            <asp:Label ID="lblChurchAddress" runat="server" CssClass="controlelements" Text="Church Address:"
                Width="120"></asp:Label>
            <asp:TextBox ID="txtChurchAddress" runat="server" Text="" CssClass="controlelements"
                Width="200" TextMode="MultiLine" Rows="4"></asp:TextBox><br />
            <asp:Label ID="lblChurchNumber" runat="server" CssClass="controlelements" Text="Phone Number:"
                Width="120"></asp:Label>
            <asp:TextBox ID="txtChurchNumber" runat="server" Text="" Width="200"></asp:TextBox><br />
            <asp:Label ID="lblEmailAddress" runat="server" CssClass="controlelements" Text="Email Address:"
                Width="120"></asp:Label>
            <asp:TextBox ID="txtEmailAddress" runat="server" Text="" Width="200"></asp:TextBox><br />
            <asp:Label ID="lblPastor" runat="server" CssClass="controlelements" Text="Pastor/Coordinator:"
                Width="120"></asp:Label>
            <asp:TextBox ID="txtPastor" runat="server" Text="" Width="200"></asp:TextBox><br />
            <asp:Button ID="btnSave" runat="server" Text="Save Details" Width="120" 
                onclick="btnSave_Click" />
                <asp:Button ID="btnDelete" runat="server" Text="Delete" Width="120" 
                onclick="btnDelete_Click" />
            <asp:Button ID="btnCancel" runat="server" Text="Cancel" Width="120" 
                onclick="btnCancel_Click" />
        </asp:Panel>

    code behind sample

    protected void Page_Load(object sender, EventArgs e)
        {
            LoadGrid();
        }
      
        private void LoadGrid()
        {
            ceHelper.DataBindGrid("Churches", ref grdChurchListing);
      
        }
        protected void grdChurchListing_SelectedIndexChanged(object sender, EventArgs e)
        {
            int index = grdChurchListing.SelectedIndex;
            txtChurchName.Text = grdChurchListing.Rows[index].Cells[2].Text;
            txtChurchAddress.Text = grdChurchListing.Rows[index].Cells[3].Text;
            txtChurchNumber.Text = grdChurchListing.Rows[index].Cells[4].Text;
            txtEmailAddress.Text = grdChurchListing.Rows[index].Cells[5].Text;
            txtPastor.Text = grdChurchListing.Rows[index].Cells[6].Text;
      
            pnlChurchList.Visible = true;
            btnAddChurch.Visible = false;
            btnSave.Text = "Update Details";
        }
        protected void btnCancel_Click(object sender, EventArgs e)
        {
            pnlChurchList.Visible = false;
            btnAddChurch.Visible = true;
        }
        protected void btnAddChurch_Click(object sender, EventArgs e)
        {
            ClearFields();
      
            btnAddChurch.Visible = false;
            pnlChurchList.Visible = true;
        }
      
        private void ClearFields()
        {
            ceHelper.ClearTextBoxes(this);
        }
      
        protected void btnSave_Click(object sender, EventArgs e)
        {
            //Run validation code here
      
            //End validation
      
            //Save data
            databankDataContext db = new databankDataContext();
            if (btnSave.Text == "Update Details")
            {
                Church updateChurch = db.Churches.Single(p => p.ChurchID == Convert.ToInt32(grdChurchListing.SelectedDataKey["ChurchID"]));
                updateChurch.ChurchAddress = txtChurchAddress.Text;
                updateChurch.ChurchName = txtChurchName.Text;
                updateChurch.Pastor = txtPastor.Text;
                updateChurch.EmailAddress = txtEmailAddress.Text;
                updateChurch.PhoneNumber = txtChurchNumber.Text;
            }
            else
            {
                Church newnewChurch = new Church();
                newChurch.ChurchName = txtChurchName.Text;
                newChurch.EmailAddress = txtEmailAddress.Text;
                newChurch.ChurchAddress = txtChurchAddress.Text;
                newChurch.Pastor = txtPastor.Text;
                newChurch.PhoneNumber = txtChurchNumber.Text;
      
                db.Churches.InsertOnSubmit(newChurch);
            }
            db.SubmitChanges();
            ClearFields();
            btnSave.Text = "Save Details";
            pnlChurchList.Visible = false;
            btnAddChurch.Visible = true;
            LoadGrid();
      
              
        }
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            int index = grdChurchListing.SelectedIndex;
            int churchID = Convert.ToInt32(grdChurchListing.SelectedDataKey["ChurchID"].ToString());
      
            databankDataContext db = new databankDataContext();
            Church deleteChurch = db.Churches.Single(p => p.ChurchID == churchID);
            db.Churches.DeleteOnSubmit(deleteChurch);
            db.SubmitChanges();
            ClearFields();
            pnlChurchList.Visible = false;
            btnAddChurch.Visible = true;
            LoadGrid();
        }



    Greetings,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  5. Jome Akpoduado
    Jome Akpoduado avatar
    16 posts
    Registered:
    07 Jan 2010
    12 Jan 2010
    Link to this post
    Hello Ivan,
    I tried to implement your suggestions but I keep coming up with an "Object reference not set to an instance of an object." This piece of logic has worked perfectly well for me in the sample page I showed earlier.
    I did another basic webuser control with just a button and a gridview control and wrote a simple handler for the button click event to load the gridview control but I still get the same error.
    Any thoughts what I am doing wrong?

    Thanks.

     


  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    12 Jan 2010
    Link to this post
    Hi Jome Akpoduado,

    Object reference is a very common error, but for sure something in your code returns null and you have not checked this (  which could be considered as a mistake in the coding). You can attach the debugger and see what exactly causes the problem.

    All the best,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  7. Jome Akpoduado
    Jome Akpoduado avatar
    16 posts
    Registered:
    07 Jan 2010
    13 Jan 2010
    Link to this post
    Thank you so much, Ivan
    It was indeed a mistake in my code (in this instance, a wrong sql connection string specified) and it is seems fine now.
    I have another question though..
    Using the Company Emerald template, how do I modify the Company name and other company specific values such as addresses, etc...
    I looked through the admin site and cannot seem to find a way to do this.

    You guys are doing a great job with this product, I tell you!.
    Thanks.

  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    13 Jan 2010
    Link to this post
    Hi Jome Akpoduado,

    "Using the Company Emerald template, how do I modify the Company name and other company specific values such as addresses, etc"

    You can check the master page in Visual Studio, some of the values are added just as text in the html. You can remove them from the html of the master page and drop a GenericContent control on the template through Sitefinity UI and move the company name , address etc there. This will allow you to manage them in the context of Sitefinity UI, instead through Visual Studio.

    Greetings,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Register for webinar
8 posts, 0 answered