This is a migrated thread and some comments may be shown as answers.

[Solved] Setting content with Razor

4 Answers 105 Views
Window
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Steve
Top achievements
Rank 1
Steve asked on 11 Jan 2011, 10:11 AM
HI,
How do I set the content of a window using Razor syntax??

@(Html.Telerik().Window().Name("Preview").Visible(false).Width(780)
      .Content(() => {
            @Model.PreviewContent
      })
      .Title("Preview").Modal(true)
)

-- this syntax causes an error, but its how I expect it to work.

And/or can I set the content html of the window from javascript?

UPDATE:
I am now creating a new Telerik window in JS and setting the content.  But, the window is off the bottom of the screen, how can I center it in javascript?

function ShowPreviewWindow(content) {
        var preview = $.telerik.window.create({
            title: "Preview",
            html: content,
            width: "800",
            modal: true,
            resizable: true
        });
        preview.center();
    }

preview.center() throws an error...

Ideally I'd like the location to be top center ... if poss?

4 Answers, 1 is accepted

Sort by
0
Steve
Top achievements
Rank 1
answered on 11 Jan 2011, 12:11 PM
To get top center ... found I can just use jQuery.

preview.css("top", "0");
preview.css(
"left", ($(window).width() / 2) - 415);

where 415 is half my window width, plus a bit for window borders etc.
0
Alex Gyoshev
Telerik team
answered on 11 Jan 2011, 01:00 PM
Hi Steve,

$.telerik.window.create returns the jQuery object that holds the window element. To get the client-side object (which has the center() method), use .data('tWindow'), as outlined in the documentation.

All the best,
Alex Gyoshev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Steve
Top achievements
Rank 1
answered on 12 Jan 2011, 01:29 PM
this doesnt work

preview.data("tWindow").center();
0
Steve
Top achievements
Rank 1
answered on 13 Jan 2011, 11:18 AM
this however does work ... weird.

var twin = preview.data("tWindow");
twin.center();



Tags
Window
Asked by
Steve
Top achievements
Rank 1
Answers by
Steve
Top achievements
Rank 1
Alex Gyoshev
Telerik team
Share this question
or