Converting 3.7 .ascx files to 5.4 widgets.

Posted by Community Admin on 04-Aug-2018 20:36

Converting 3.7 .ascx files to 5.4 widgets.

All Replies

Posted by Community Admin on 18-Mar-2013 00:00

What's the best way of doing that?

I have fully functional web control .ascx files with their associated .cs back end server code files. I have tried dropping in the files "as is", but when I do all the page objects appear as not recognised in the current context.

Also:

telerik:RadScriptBlock
telerik:RadTextBox
telerik:RadMaskedTextBox


show up as unrecognised, even thought I have at the top of the .aspx page the:

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

tag. So that should register the assembly, you would think.

So is there any way I can drop in completed .ascx files into Sitefinity 5.4? Or do I have to scrap all my work, and rebuild them through the widget designer?

Posted by Community Admin on 19-Mar-2013 00:00

Thats wierd, it should accept them "as is"....as long as you dont have any 3.7 api calls going on

Have you tried commenting out the entire code-behind (building) and see if anything renders?

Posted by Community Admin on 19-Mar-2013 00:00

Tried that, commenting out the back end, and everything compiles OK.

Also, I am going through the documentation on creating a template, using the same front end tags, and I getting the same "is not a known element" error, with the green squiggly underlines, on those telerik tags.

Another thing too, that this error crops up with Telerik's own demonstration code. To illistrate:

1.  I follow ALL the steps on this page:

www.sitefinity.com/.../creating-a-template

Right upto the "Filling the template" section. Then on step 3, I copy in the following code from the page:

<%@ Register TagPrefix="sf" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %><sf:RadRotator id="RadRotator1" runat="server" RotatorType="SlideShow"></sf:RadRotator>

When I put the code into my .ascx file within Visual Studio, guess what I see:

View Screenshot

Yes, you guessed it, the green squiggly line under the text "RadRotator". So even their own code does not work, or that Visual Studio is confused. I'm not sure.




Posted by Community Admin on 19-Mar-2013 00:00

...but compiles and renders fine right, you just mean VS or JC are honkin at it?

Posted by Community Admin on 19-Mar-2013 00:00

It compiles, not sure how to see if it is rendering. Still trying to figure out how to set up the template, with custom controls under 5.4.

Posted by Community Admin on 19-Mar-2013 00:00

If it's just a Usercontrol you don't really need to set anything up aside from put the control in the webroot, register it in the toolbox with ~/folder/MyControl.ascx, build

Should be drag\drop from there.  Doesn't even need to be registered in the toolbox to use either, that's only if you need to to be drag\droppable.

Posted by Community Admin on 19-Mar-2013 00:00

Nope, tried what you did and ended up with a 164 Errors. Which is what I encountered when I first tried that course of action.

When I try to drag and drop an .ascx file into my project:

1. All the asp objects lose their context, on the back end. On the front end of the .ascx file things look OK, eg:

<asp:Label ID="lblCList1" runat="server" CssClass="lblDateBox" Text="* You must click on the checkbox to complete the application"></asp:Label>



but on the back end

lblCList1.Visible = true;



Fails, as the "lblCList1" text throws a "does not exist in current context" error. It is like all the asp objects loose their properties as objects, so when they are used on the back end, they are unknown.

I am using a code behind statement at the top of the .ascx page:

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ScholarshipPublic.ascx.cs" Inherits="ScholarshipPublic" %>




So you would think it should find the back end file, but no... it's all gone to crap.

Also, I have to say that when I started this I used the "Widget with designer", from the Sifefinity Thunder start page. Not sure if this was the correct choice, as I still don't have a full understanding of all this new Sitefinity functionality.

Posted by Community Admin on 19-Mar-2013 00:00

Did you right-click on the control and go to Convert to WebApplication?

Posted by Community Admin on 19-Mar-2013 00:00

No, was I supposed to do that? Nothing in the Sitefinity documentation told me to do that.

I'll give it a shot, thanks.

Posted by Community Admin on 19-Mar-2013 00:00

That's not a sitefinity thing, it's an asp.net web application thing.  Website projects just need the .ascx and the .cs...a webapp needs the .designer.cs file too in order to link the ascx to the .cs

Sitefinitys "Simpleview" widgets (thunder will make them for you) do something similar, you just need to tell the .cs about the controls like this

protected virtual Label controlInAscx
    get return this.Container.GetControl<Label>("controlInAscx", true);
...and maybe wire up some events with += in CreateChildControls or InitalizeControls

So it's VIRTUALLY a copy\paste to make them a simpleview control

Posted by Community Admin on 19-Mar-2013 00:00

So should I do anything with Sitefinity Thunder at all, for premade .ascx files?
Just do them as a standard .asp web application and add them to the toolbox?

Posted by Community Admin on 19-Mar-2013 00:00

Well I mean Sitefinity supports plain Usercontrols...but I've had issues in the past with like button-clicks not firing (I think that was it)

So I've stopped making those and isntead opt for the Thunder-generated Simpleview widgets ("Widget with Designer" is the template I use, you can just delete the designer files if you dont need them)

...but yeah it'll AUTO-register the controls in the toolbox

It's up to you, if your usercontrols work as is...might as well just go ahead and use them like that.

Posted by Community Admin on 19-Mar-2013 00:00

No, no. I'll have to learn this new widget technology with 5.4, it's just that I've finally mastered 3.7 and now I have to throw all that away and relearn EVERYTHING. I'm just frustrated that I don't have proper learning materials at hand. The online stuff is helpful, but not complete.

Posted by Community Admin on 19-Mar-2013 00:00

It's not as complex as you think :)  I converted set of 5 complex .ascx usercontrols from a website project into sitefinity SimpleView controls in 20 minutes, all work just fine.

It's almost LITERALLY a copy\paste

Custom Designers are clientside, so that's different...but not complex; actually here's a tip.  If you generate the Widget+Designer, then DELETE the designer and go about adding your properties and things.  If you then use Thunder to "Create designer for existing widget" it'll read that widgets properties and auto-generate it all for you...even like page\content pickers if you have Guid fields.

Steve

This thread is closed