I created two templates known as Home and products. In that i have to add codebehind for the products template. I dont know how to add code behind in umbraco. Help me....
I already created a codebehind for that productpage in visualstudio2008. I just want to connect that codebehind file to the producttemplate i created in umbraco.How can i do it?
That example is good. i explain my case to u, i created a homepage and productspage in VS2008. In that, productpage holds a listview which is populated by the values given from the homepage.For that i written in the productpage codebehind file as follows,
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.Odbc;
using System.Text;
public partial class _Default : System.Web.UI.Page
OdbcCommand cmd = new OdbcCommand("select * from productmst2 INNER JOIN productgrp on productmst2.GroupID = productgrp.GroupID where productgrp.GroupID = '" + id + "'", conn);
OdbcDataAdapter da = new OdbcDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
ListView2.DataSource = dt;
ListView2.DataBind();
}
catch (Exception ex)
{
}
}
}
It works fine in VS2008. But i want to do the same in umbraco. How can i do it? is it possible to do that by usercontrol?
How to add codebehind to a template?
Hi all,
I created two templates known as Home and products. In that i have to add codebehind for the products template. I dont know how to add code behind in umbraco. Help me....
Thanks in advance
Hari
Hi Hari,
what about writing your codebehind in a usercontrol and inserting that as a macro in your template?
Will this fulfill your requirements?
Matthias
Matthias thanks for ur reply.
I already created a codebehind for that productpage in visualstudio2008. I just want to connect that codebehind file to the producttemplate i created in umbraco.How can i do it?
Hi,
have a look at this short Screencast from Tim: http://www.nibble.be/?p=12%20%28
Matthias
Hi Matthias,
That example is good. i explain my case to u, i created a homepage and productspage in VS2008. In that, productpage holds a listview which is populated by the values given from the homepage.For that i written in the productpage codebehind file as follows,
besides that i don't know where the url paramter "GroupID" is coming from, you can transfer your code to a usercontrol and it should work.
Hari,
You should move your code to a user control and add that as a macro on to your products template just as Matthias explained in earlier posts.
Cheers,
/Dirk
Thanks Matthias and Dirk. I am going to try ur suggestions...
You could try this solution https://umbracocs.codeplex.com/
It will create exactly what you're after!
is working on a reply...