cancel
Showing results for 
Search instead for 
Did you mean: 

Pulling data from .ascx files up to .master files

Former Member
0 Kudos
101

I'm trying to use some basic info from .ascx files, like product code, in my catalogpartdetail.master. How do I pull that data up? If you could post some sample code, that would be the easiest for me to imitate.

Thanks,

Derek

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

If you look in the plugins folder for WebTools all the files have their code in the ascx file (not a code behind) so that would be a good place to see examples of how to access the API.

Steve

Former Member
0 Kudos

I pasted this from the partdetail.aspx into the common.master file, so that the heading for my main content section would be the name of the product, but it returns 0 data. I'm sure that I'm just not linking it to the right data source, but I don't know how to do that.

<asp:Label ID="sysPartName" runat="server"></asp:Label>

The end result I'm looking for is to have a big switch statement in the .master file that loads titles based on whatever file and data detail is currently loaded. By pulling the data up to the .master level, I avoid having to add information to every .ascx and .aspx file, making upgrades infinitely easier.

Thanks,

Derek

Former Member
0 Kudos

If you want to make a custom header for each of the parts, the easiest way to do it is to make a plugin which gets the part ID from the URL. Then on the partdetail.master page embed the ascx control. You cannot execute code directly from master pages or ASPX pages. (You can execute code, but it is improper ASP.NET code execution.)

Former Member
0 Kudos

This should help get you started with your plugin:


<%
{
		if ((Request.QueryString["ListType"]) == "F"){
		categoryName.Text = @"Featured Products"; categoryName.Visible = true; 
		}
		else if ((Request.QueryString["ListType"]) == "N"){
		categoryName.Text = @"New Products"; categoryName.Visible = true; 
		}
		else if ((Request.QueryString["ListType"]) == "D"){
		categoryName.Text = @"Sale Items"; categoryName.Visible = true; 
		}		
		else if ((Request.QueryString["ParentID"]) != null){
		NPCatalogCategory pc = new NPCatalogCategory(Convert.ToInt32(Request.QueryString["ParentID"])); 
		categoryName.Text = pc.CategoryName; categoryName.Visible = true; 
		}
		else if ((Request.QueryString["CategoryID"]) == null || (Request.QueryString["CategoryID"]) == ""){
		categoryName.Text = @"";
		}
		else { 
		NPCatalogCategory c = new NPCatalogCategory(Convert.ToInt32(Request.QueryString["CategoryID"])); categoryName.Text = c.CategoryName; categoryName.Visible = true; 
		}
}
%>
<asp:Label ID="categoryName" CssClass="categoryHeader" runat="server" visible="false" />

Answers (1)

Answers (1)

Former Member
0 Kudos

I'm sorry if my questions are really lame, but though I'm a decent programmer in multiple other languages, I'm having to learn both ASP and Webtools at the same time, so I don't always know if my problem is just simple programming misunderstandings or if it is how Netpoint implemented something.

I made a test plugin, put it in the banner slot, copied in the includes from another plugin, then pasted in your sample code (see below). It doesn't seem to be returning anything, but I can't figure out why. What am I doing wrong?

<%@ Register TagPrefix="NP" Namespace="NetPoint.WebControls" Assembly="NetPoint.WebControls" %>
<%@ Control Language="c#"%>
<%@ Import Namespace="netpoint.classes" %>
<%@ Import Namespace="netpoint.api.catalog" %>

<%
{
		if ((Request.QueryString["ParentID"]) != null){
		NPCatalogCategory pc = new NPCatalogCategory(Convert.ToInt32(Request.QueryString["ParentID"]));
		categoryName.Text = pc.CategoryName; categoryName.Visible = true;
		}
		else if ((Request.QueryString["CategoryID"]) == null || (Request.QueryString["CategoryID"]) == ""){
		categoryName.Text = @"";
		}
		else {
		NPCatalogCategory c = new NPCatalogCategory(Convert.ToInt32(Request.QueryString["CategoryID"])); categoryName.Text = c.CategoryName; categoryName.Visible = true;
		}
}
%>
<asp:Label ID="categoryName" CssClass="categoryHeader" runat="server" visible="false" />

Former Member
0 Kudos

Derek,

Plugins must be an .ASCX file in the PLUGINS directory which you can find under your B1Webtools folder. Once your ASCX file is in the PLUGINS direcotry, you will be able to add a new slot to your theme. Choose slot type PLUGIN and you will see all of the plugins in the drop down below. Select your plugin and it will display on your theme.

There is no embedding necessary. It is not necessary to edit the master page or any ASPX files. The system is created to display plugins in whatever slot you would like (banner, left, right, main, base...)

If you see the name of the plugin in plain text on your theme, that means there is something programatically wrong with the code.

To debug a plugin, I usually use an ASPX file called webform1.aspx located in your plugins directory. In the header of this file you can point to your ASCX plugin. Then in your browser type http://localhost/b1webtools/plugins/webform1.aspx

This will allow you to see any program errors.

I hope this helps.