1

I ask a relevant question here and as I find there is no way to use custom control in Razor views, so I get to add new ASPX partial view to use custom control, my custom control is a dll that I added to References then define Partial view as the following:

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<System.DateTime?>" %>
<%@ Register Assembly="JQControls" Namespace="JQControls" TagPrefix="PersianDatepicker" %>
<PersianDatepicker:JQLoader ID="jqdb" runat="server" />
<PersianDatepicker:JQDatePicker ID="jqdp1" runat="server" Regional="fa" />

I write the exact code in ASPX Web form and worked correctly but there is an exception in MVC:

Error executing child request for handler 
'System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerWrapper'.

Exception of type 'System.Web.HttpUnhandledException' was thrown.

Object reference not set to an instance of an object.

So does any one have any idea about it?

Another question is how can I define a Html Helper for this user control (With dll and I have not access to code) ?

Community
  • 1
  • 1
Saeid
  • 13,224
  • 32
  • 107
  • 173

2 Answers2

2

make a html iframe into view, loading a aspx page!

sephilin
  • 21
  • 2
0

the "View" in MVC template should be standard HTML form.

you may use "Helper" to generate complex/re-useable HTML output but using any standard HTML+Javascript in UI is the way "MVC" works.

MVC allow parallel coding and HTML development. any developer who knows HTML+JS can create "View" without messing up your code.

this jquery plugin http://jqueryui.com/demos/datepicker/ can create custom DatePicker on client browser.

aifarfa
  • 3,939
  • 2
  • 23
  • 35