Build A Composite Or Template Control In MVC Or The Equivalent?

May 10, 2010

In our current ASP.Net Webforms application we have several composite/template server controls that only exist for a common look and feel. For example, we have a panel control that has a title, a place for buttons related to the contents of the panel, and of course the contents. How is this best accomplished in MVC? RenderPartial doesn't get done what I need here. Should I still be using the same controls, but just on a view page? These controls don't really do anything on postback, they are only there for a common look and feel.

More Info:

We have a control in Webforms that implements ICompositeControl. We have a few properties on this control like Panel (type Panel), Buttons (again type Panel which would hold buttons) and a property Title of type string. Visually it looks like

View 2 Replies


Similar Messages:

ADO.NET :: Does Entity Framework 3.5 Support Composite Foreign Key/Composite Primary Key

Dec 14, 2010

Does ADO.Net Entity Framework 3.5 support Composite Foreign key/Composite primary key?

View 5 Replies

Forms Data Controls :: How To Programmatically Build A Template For Datalist

Sep 5, 2010

i want to write a page contain an datalist and several ObjectDataSource. The datalist will chose ObjectDataSource according to QuerryString passed to that page.

My idea is like:

[Code]....

I searched and read [URL]

View 1 Replies

Html - Generate Static Web Pages From A Template As Part Of Web Application Build?

Oct 13, 2010

I'm building an HTML5 application (with ASP.NET back-end) and i want to develop it in such a way that i can run it locally with all my resources (such js and css) not minified (so i can debug it easily). However when i build the final version i want merge and minify the resources. At the same time i want to create several versions of the app targeting different platforms (iPhone, iPad, desktop, etc) by adding appropriate css.

I thought that the final output should be a set of html files (so the get cached nicely). I could use ASPX and just control the output by a query string parameter, but i don't really want to have the form tag on my page.

So the questions are:

What are the pros and cons of using static html pages generated from a template versus a dynamic ASPX page? (apart from being able to run on any web server)
If ASPX approach good enough then how can i get rid of the form tag that's required by ASP.NET?

UDPATE

Another factor in favor of static html pages is the fact that the files are served instantly, whereas ASPX may take awhile to load if the app has recycled.

The back-end is ASP.NET 2.0.

View 2 Replies

AJAX :: Creating New Composite Control To Make A Full Calendar Control?

Jan 11, 2011

i create new composite control to make a full calendar control.

[Code]....

All is good until i put

[Code]....

View 2 Replies

Custom Server Controls :: To Include Rating Control In A Composite Control?

Feb 12, 2010

I am trying to included a rating control in a composite control that renders many different type of controls. I render the controls by overriding the rendercontents so that I can control the layout of the controls. When I try to add the rating control to the output i get a Page cannot be null error. Can someone provide me with the proper way to render a rating control from a composite control and be able to control the layout of the child controls.

View 3 Replies

Web Forms :: Assignment Of FormView Control In Design-time To User Defined Composite Control

Feb 1, 2011

i create a composite control as can be seen in code below, and add this control to webform, assign FormView1 to the HeaderControlName property, Run the page, the system will generate parse error message :
Cannot create an object of type 'System.Web.UI.WebControls.FormView' from its string representation 'FormView1' for the 'HeaderControlName' property. However, if i don't assign FormView1 in design screen and manually (through coding) assign FormView1 to the custom control on init, it works as expected.

custom control
public class CmdTest : CompositeControl
{
public virtual FormView HeaderControlName
{
get
{
object oObject = ViewState["HeaderControlName"];
return (oObject == null) ? null : (FormView)oObject;
}
set
{
ViewState["HeaderControlName"] = value;
}
}
protected override void CreateChildControls(
{
Controls.Clear();
Button xx = new Button();
Controls.Add(xx);
}
}
webpage.aspx (assign FormView1 in design time, it will generate error)
<Utils:CmdTest ID="CmdTest1" runat="server" HeaderControlName="FormView1" />
webpage.aspx (didn't assign FormView1 in ASPX, but assign it on Init Code, it works)
<Utils:CmdTest ID="CmdTest1" runat="server" oninit="CmdTest1_Init" />
Webpage.aspx.cs
protected void BsCmdTest1_Init(object sender, EventArgs e)
{
CmdTest1.HeaderControlName = FormView1;
}

View 2 Replies

AJAX :: Error When Rendering A Rating Control In A Composite Control?

Feb 11, 2010

I have a custom control that renders different controls based on a property value. This all works correctly until i try and add a rating control to the control. When i render both controls in the CreateChildControls the control is rendered properly.

However when i try to add layout by overriding the RenderContents method and rendering controls there, an error is generated
Extender controls may not be registered after PreRender.The code shows both methods of creating the controls.

[Code]....

View 2 Replies

Registering A Composite Control?

Dec 13, 2010

I am learning custom controls and just finished my first one. The problem is that I am struggling to register it in my web config and have the compiler recognize it. Right now this results in a YSOD about the reference to the control.

note: exact error - Error Unknown server tag 'cc:LblTextBox'.

Web Config

//..
//..
<pages>
<controls>
<add tagPrefix="cc" namespace="Controls.Server"/>
</controls>
</pages>
</system.web>
The control code-behind
namespace Controls.Server
{
public class LblTextBox : CompositeControl
{
//...
}
}
mark-up
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ControlsMain.aspx.cs" Inherits="Pages_ControlsMain" Trace="true" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Controls Area</title>
</head>
<body>
<form id="form1" runat="server">
<div>
First attempt at a simple composite control <br />
<cc:LblTextBox ID="ccLblTbHybrid" runat="server" LabelText="Name:" />
</div>
</form>
</body>

View 2 Replies

How To Convert A User Control To Web/Composite Control

Feb 10, 2010

Is there a simple process to convert an user control to a web/composite control?

View 1 Replies

C# - Converting Listview To A Composite Control?

Mar 8, 2010

The link below shows a listview composite control in its most basic form however I can't seem to extend this to what I'm trying to do.

http://stackoverflow.com/questions/92689/how-to-define-listview-templates-in-code

My listview has 1 tablerow with 2 fields. The first field contains 1 element whilst the second field contains 2 elements as shown below.

<asp:ListView ID="lstArticle" runat="server">
<LayoutTemplate>
<table id="itemPlaceholder" runat="server"> [code].....

View 1 Replies

Adding Jquery Into A Composite Control?

Jun 28, 2010

I am creating a composite control that has a textbox and uses a jquery plugin to add a watermark. Lets say I have a basic function that looks like this

$(function () {$('#MyTextBoxID').watermark('Enter your username');});

Can anyone suggest what I need to do to insert the above?

View 1 Replies

Does A Composite Server Control(inc. User Control, Custom Server Control) Normally Encapsulate Css Properties?

Nov 7, 2010

If a composite server control normally encapsulate styling information inside, it is an example of code encapsulation and modularization. However if css properties are included inside the composite control, it is not ideal for code/styling separation and css code re-use principles. Now which consideration should be the main consideration?

View 2 Replies

How To Enhance A Composite Control's Client Side

Aug 30, 2010

I want to enhance a composite control's client side, my approach is to recreate all method on JavaScript, so here I have some troubles :

1) Can I call onclick event on client side otherwise on server side ?

2) the statement table.onclick=SelectRow(event) fires a bug !

View 6 Replies

AJAX :: Access ScriptManager In Composite Control?

Oct 4, 2010

Can anybody tell me how can i access ScriptManager in my Composite Control?

I do have reference of system.web in my project but when i type System.Web.UI.

i am not able to get reference of ScriptManager afeter UI.

The reason for doing this is that i have a composite control which is registering some client script on OnPreRender event.

this control works fine when placed on web page without update panel but gives error "object expected" when placed in an update panel

i am registering client script as follows

[Code]....

View 5 Replies

How To Save Value Across Postbacks For A Composite Control Without Using Viewstate

Oct 29, 2010

I have a composite control that has a couple of private fields that reference values in the cache and these private fields are called during the constructor method. Since a string key is used to identify the value in the cache, I must have a way of storing that string key in such a way that it is available at the time the control is instantiated, and I have to be able to reference it on postbacks without it changing.

In addition, this key is generated the first time the control is loaded, but it should not be changed again after that first time.

How can I accomplish this?

I have already tried saving it to viewstate, but that doesn't work because viewstate is not yet available at the time the control is instantiated.

I have tried using a private field and then checking against Page.IsPostback in the constructor and if it isn't postback, I assign a value to the private field, but on subsequent postbacks it looses it's value, and I can't reassign it in the Page.IsPostBack again because it is an autogenerated GUID.

View 3 Replies

C# - Simple Composite Control - Postback Not Working?

Nov 17, 2010

I am trying to make a simple composite control - just a label and textbox - but the postback isn't being picked up by the control.I haven't implemented IPostBackDataHandler as according to this its not necessary - the TextBox control should tie in automagically. A composite control that includes a TextBox need not worry about postbacks, as the embedded control will work it out with ASP.NET automatically.

class TestControl : WebControl
{
Label _label;

[code]...

View 1 Replies

C# - Creating Composite Control With Client Feature?

Nov 7, 2010

I want to develop composite control where some of the work would be executed on client side. For that I am implementing IScriptControl.

ScriptReference points to a script file with client object.

Let's say I want it to have Listview(html select) control that onselect will run javascript function based on the selected value.

I can't just create the control dynamically is client js, because the control has UI on design mode so I must create the select control on server side (I create it in override void Render)

My problem how and where to assign the onselect event for the selection.

Update: Maybe I should add select's id as property to ScriptControlDescriptor, then in client control retrieve this id and attach the needed handler to the event?

View 3 Replies

Web Forms :: Composite Control Attribute Assignment?

Mar 29, 2010

I have got a composite control and i would like to dictate which attribute/property is assigned to the control first from the markup?example in the aspx file:

<MM:MyControl ID="" runat="server" ViewType="normal" BaseType="RealBase"></MM:MyControl>

when the control gets created from the mark-up above, ViewType will be assigned first, Which is what I do not want, I would like RealBase to be assigned first under all circumstances. This control is to be users by other developers so I cannot just switch the order.

View 1 Replies

How To Get A Composite-control's Child Controls At Design-time

Jun 23, 2010

I am designing an ASP.NET v3.5 custom control based on CompositeControl.

However, I do NOT want to create my child controls via code, but rather as

embedded HTML tag elements within the CompositeControl in the ASPX page, such as:

[code]....

At run time, MyControl.Controls contains the two labels as expected.

At design time, MyControl.Controls is empty.

I need this information at design time for various reasons.

What am I doing wrong?

View 1 Replies

C# - How To Retrieve The URL Address Of A Page Hosting Composite Control

Dec 8, 2010

I have a composite control, I need to get the address of page hosting it.

View 1 Replies

DropDownList Within Composite Control Is Losing Selected Value On Postback

Feb 23, 2010

I am building a composite server control that currently only has a TextBox and a DropDownList. Here is the code in all its foetal glory:

[Code]....

The control appears to work correctly across postbacks, that is until declarative values are set, e.g.:

<squee:Address runat="server" ID="a" Street="123 Fake St" State="VIC" />

After this, the text box continues to work correctly, but the _state member does not pick up the posted back values and instead just sticks to the declared value. I've checked the raw posted values in the Request object, and the new value for the list's UniqueID is there, but _state doesn't pick it up.

View 1 Replies

C# - Composite Control Property That Allows Coder To Select From Options?

Mar 16, 2010

The question is in the title but to make it clearer when you use a normal server control like

<asp:textbox />
<CC1:CtrlArticleList SortBy="Title" ID="compositeControlArticleList" runat="server" />

the properties of textbox allow you to select from a dropdown list (eg visibility=...true or false). How do I replicate this in composite control?

Added code since question asked:

[code]....

View 1 Replies

Add Ability To Provide List Items To Composite Control With DropDownLIst?

May 7, 2010

I'm creating a composite control for a DropDownList (that also includes a Label). The idea being that I can use my control like a dropdown list, but also have it toss a Label onto the page in front of the DDL.

I have this working perfectly for TextBoxes, but am struggling with the DDL because of the Collection (or Datasource) component to populate the DDL.
Basically I want to be able to do something like this:
<ecc:MyDropDownList ID="AnimalType" runat="server" LabelText="this is what will be in the label">
<asp:ListItem Text="dog" Value="dog" />
<asp:ListItem Text="cat" Value="cat" />
</ecc:MyDropDownList>

The problem is, I'm not extending the DropDownList class for my control, so I can't simply work it with that magic. I need some pointers to figure out how I can turn my control (MyDropDownList), which is currently just a System.Web.UI.UserControl, into something that will accept List items within the tag and ideally, I'd like to be able to plug it into a datasource (the same functions that the regular DDL offers).

I tried with no luck just extending the regular DDL, but couldn't get the Label component to fly with it.

View 2 Replies

Web Forms :: Composite Control Loses Subscribed Event/delegate?

Jan 18, 2010

I have created a custom composite control basically with two checkboxes. I have created a subscribable event, and the consumer has subscribes to it. But when I go to excute it, the delegate reference is null. What am I missing and why is it losing its subscribed events?

[Code]....

I am using VS2008 SP1 targeting .Net 2/3.5SP1 web site.

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved