Thickbox in asp.net mvc - asp.net-mvc

I want to use Thickbox in my site.
I have the following code:
<img src='#Url.Action("GetSchemaImage", "Hall", new {folderName = #Model.FolderName })'/>
This is generated markup:
<a class="thickbox" href="/Hall/GetSchemaImage?folderName=marineclub"><img src="/Hall/GetSchemaImage?folderName=marineclub"></a>
The image shows correctly, but when I click on it, it opens in the current window.
How to resolve it?
Thanks

try another signature for the HTML ActionLink helper and see if this works
#Html.ActionLink("GetSchemaImage", "Hall",new {folderName = #Model.FolderName },new{})

Related

Open each router link as a new tab in an Electron app

I am using electron with angular 5. Trying to open each router link as a new tab but I am not finding anything that could help me to achieve this. Is it possible to achieve?
Have you tried adding target="_blank" to you tag? You could also try a click navigation function as well.
<a routerlink="someUrl" target="_blank">
or
<a routerlink="someUrl" (onClick)="navigate(someUrl)">
public navigate(url: string):void {
window.open(url);
}

UMBRACO: How to add image on template

So, I'm currently new to Umbraco and I'm following some tutorial videos on umbraco.tv. I have created my template and is currently using it to setup the Home Page for my website. I have all the front end working and its displaying properly.
My problem is on the images. I'm using a lot of images for my website and I'm trying to link it to content so the images can be easily changed(not sure if I'm making sense).
Navigation bar image
If you click the link above, that's how my current navigation bar look like. I want to be able to change the LOGO using Umbraco's media picker. However, everytime I do so, it either gives me the alt name or a runtime error.
This is the code for the image on the template.
<img src="#Umbraco.Field("navigationLogo")" height="100" width="50" alt="Logo">
I'd appreciate it if you can help me. I'm not sure if I've explained it properly so feel free to ask in detail. Thanks!
Edit -----
I am only coding on browser since it doesn't allow me to login to pull the codes locally (only on trial version since I'm just testing out if its a good CMS).
Not sure if I'm doing it correctly so I apologize. I wrote my code like this
#{
var navigationLogo = #Umbraco.AssignedContent.Site().GetPropertyValue("navigationLogo");
var navigationLogoMediaItem = #Umbraco.TypedMedia(navigationLogo);
<img src="#navigationLogoMediaItem.Url" height="100" width="50" alt="Logo" />
}
It's giving me the following error so far.
Compiler Error Message: CS1061: 'Umbraco.Web.UmbracoHelper' does not contain a definition for 'AssignedContent' and no extension method 'AssignedContent' accepting a first argument of type 'Umbraco.Web.UmbracoHelper' could be found (are you missing a using directive or an assembly reference?
#inherits Umbraco.Web.Mvc.UmbracoTemplatePage
#{
Layout = "WebBase.cshtml";
string navigationLogoMediaItem = "";
if (Model.Content.HasValue("navigationLogo"))
{
navigationLogoMediaItem = Model.Content.GetPropertyValue<IPublishedContent>("navigationLogo").Url;
}
}
<img src="#navigationLogoMediaItem" height="100" width="50" alt="Logo" />
you can try this
I'm going to make a few assumptions so please bear with me here.
Assumption 1) On your home node (assuming a document type of 'home") you have a property on it called "navigationLogo".
Assumption 2) This is a media picker data type
Assumption 3) You are using Umbraco 7.6 or newer.
Assumption 4) You aren't using Models Builder
So, assumptions in place there are a few steps you need to go through.
1) Get the navigation logo where ever you are in the site.
var navigationLogo = #Umbraco.AssignedContent.Site().GetPropertyValue("navigationLogo");
2) next, you'll need to get the media item as I belive you will only have a UDI at this stage.
var navigationLogoMediaItem = #Umbraco.TypedMedia(navigationLogo);
3) You'll want to put a null check in at this point but to get the url of the logo you simple need to do this:
<img src="#navigationLogoMediaItem.Url" height="100" width="50" alt="Logo" />
That should get you what you are after. :-)
You can simply try out this code.
memberImage is your document type field name
#{
var image = Umbraco.TypedMedia(#Umbraco.Field("memberImage").ToString());
<img src="#image.Url" style="max-width:250px">
}

ActionLink MVC4 Razor with icon class

I have this code HTML:
<a class="tooltip-tip2 ajax-load" href="...."><i class="entypo-menu"></i><span>Page Example</span></a>
And I would use this:
#Html.ActionLink("Crea mensilizzazione " + s.nome, "CheckCredentials", "giornaliero", new { #class= "tooltip-tip2 ajax-load" , id=s.id, isScuole = false},null)
How can add the <i class="entypo-menu"></i> in this #HTML.ActionLink???
I don't think the ActionLink helper can accomplish this. but you can use #Url.Action() in custom markup to accomplish the same thing:
<a class="tooltip-tip2 ajax-load" href="#Url.Action("CheckCredentials", "giornaliero")"><i class="entypo-menu"></i><span>Page Example</span></a>
Url.Action basically just creates the URL for the link, not any of the markup related to building the link itself. So it can be used in all sorts of custom client-side code. (For example, another common use is to embed it in some JavaScript code to define an AJAX service URL.)
Edit: You can add route values exactly the same way as you do with #Html.ActionLink:
#Url.Action("CheckCredentials", "giornaliero", new { id = s.id, isScuole = false })

Print all steps of asp:Wizard control

I have a asp:Wizard control in my Web Application.I need to be able to print at any step within the wizard , and print all steps up to that step not just the current step.
I've added a print button to every step page , and tried to call the javascript:window.Print(), but only the current step gets printed.
How do i get all the steps to print in 1 page?
i'd like to try and get this working in javascript first before i go down the PDF route . I've tried doing somehting like this :
protected void Page_Load(object sender, EventArgs e)
{
StringWriter sw = new StringWriter();
HtmlTextWriter tw = new HtmlTextWriter(sw);
this.WizardStep2.RenderControl(tw);
string wizardHtmlContent = sw.ToString().Replace("\r\n", "");
string printScript = #"function printDiv(printpage)
{
var headstr = '<html><head><title></title></head><body>';
var footstr = '</body>';
var newstr = printpage;
var oldstr = document.body.innerHTML;
document.body.innerHTML = headstr+newstr+footstr;
window.print();
document.body.innerHTML = oldstr;
return false;
}";
this.Page.ClientScript.RegisterStartupScript(this.GetType(), "PrentDiv", printScript, true);
this.Button1.Attributes.Add("onclick", "printDiv('" + wizardHtmlContent + "');");
}
and for the aspx:
<form id="form1" runat="server">
<div>
<asp:Wizard ID="Wizard1" runat="server">
<WizardSteps>
<asp:WizardStep ID="WizardStep1" runat="server" Title="Step 1">
step1
</asp:WizardStep>
<asp:WizardStep ID="WizardStep2" runat="server" Title="Step 2">
step2
</asp:WizardStep>
</WizardSteps>
</asp:Wizard>
<asp:Button ID="Button1" runat="server" Text="Button" />
</div>
</form>
But i'm getting a missing runat=server error on line 3 , when i attempt to render the wizard control , so i think i may need to create a new window, then output the string before i print it , but cant seem to get that working ...Anyone any ideas ?
i have found a solution for my problem , i didnt manage to accomplish it client side , but ive managed to solve it server side which is better than going down the PDF route which i didnt want to do.
I found a great article here :
Printing in ASP.NET
which i ammended to print all steps of my wizard control in one go. thanks for all your help.
The javascript print method you're already using will work if you put the wizard steps in to a single page so they all render ...
the other way I guess is to simply browse to each step and hit your print button.
the way I would do it is use something like pdfsharp and give it the markup generates by each step and tell it to create a pdf page for each steps worth of markup ... from there the user has a pdf doc which they can simply view save or print using their usual pdf viewer.
The problem is that the javascript method is using a dom based api call to ask the browser to print the page which of course ultimately means you can only print the wizard step you're currently looking at ... using the pdf method means the user can preview the expected print out before printing and you have more control over what's printed.
It does require a bit more code though ...
pdfsharp can be found here: http://www.pdfsharp.net/Downloads.ashx
As you can see its free and open source.

Using Html.ActionLink() with ASP.NET MVC & Spark - Syntax?

All,
Doing some experimenting with Spark and MVC within NerdDinner. The normal/aspx view works well, and I haven't touched any of the controller code so I'm pretty sure it's not that.
<viewdata model="System.Collections.Generic.IEnumerable[[NerdDinner.Models.Dinner]]"/>
<set Title="'Upcoming Dinners'"/>
<content:main>
<li each="p in Model">
!{Html.ActionLink(p.Title, 'Details', 'Dinners')}
</li>
</content:main>
Given the code above, the ActionLink gets rendered as http://serverName/Controller/Action/
Which is good. I start hitting a wall when I try to provide the ID to my action method. As far as I can tell from the Spark sample docs, I should be able to do something like this:
!{Html.ActionLink(p.Title, 'Details', 'Dinners', new {id = p.DinnerID} )}
However, that throws an exception:
" unexpected token '{' "
I'm hoping it's something silly I'm missing...any suggestions?
I believe there should be another parameter to Html.ActionLink for HTML attributes on the action link. Try:
!{Html.ActionLink(p.Title, 'Details', 'Dinners', new {id = p.DinnerID}, null )}

Resources