User control in Umbraco - umbraco

Hey frenz I am new to Umbraco cms. And I am building site using it.Here I need to include the
.net user control with some textboxs and submit button. But when I include the macro containing the .net user control in my templete and Run the site I got the error
Server Error in '/' Application.
Control 'ContentPlaceHolderDefault_News_2_Button1' of type 'Button' must be placed inside a form tag with runat=server.
I also watch the video tutorials about the Usercontrol in Umbraco. And followed the same process but i am still getting the error.
But it works fine if i used Html textbox and buttons
So, it there any solution for it.............

This is because the control 'ContentPlaceHolderDefault_News_2_Button1' of type 'Button' is not placed inside a form tag with runat=server.
Every ASP>NET control that have attribute runat="server" must be placed inside a form tag with runat=server.
The solution is easy:
Put the form into your user control
or
Make template that contains server form and acts as master page. Put your user control inside that template

Related

How to add an external link under a page in Kentico?

We’re using Kentico 11.0.26 with MVC.
I need to add an external link under a page.
In content tree it should look something like this:
Page A
Page A1
Page A2
https://www.www.google.com/
The problem is that when I click the + button in Pages application, I only see page types, and there is no option to add a link.
Why not use value of page field to store the link and load the value inside of MVC app? Content tree alone does not have capability for this. All nodes have to be pages in one way or the other and plain old link to external domain can not be placed instead of page. To be honest I do not see benefit of having a link inside of content tree even for menu since you have to create menu using document path and not only its name anyway so accessing additional property should not be that much of a problem.
You could create a new content type to represent an external link and put that into your content tree. This would then also give you options to set additional properties of the link such as target and title rather than just a URL.

Can we check if page already has a form and avoid inner forms in jsf 2.2

We create command links on a page. The same command link is sometimes used on a different page of the web site. When first created because Page A does not have a form.
Scenario 1
Page A (no form on page)
Some text
Need a link. So, create command link surrounded by a form.
Scenario 2
Page B (reuse commandLink from Page A on page B)
<h:form>
Some text
Need a link. So, create command link surrounded by a form.
Reuse commandlink component from PageA
</h:form>
Throws an error, inner form exception.
Cannot use h:link because of url issues.
Can we use h:outputLink instead of commandLink to avoid form issues?
Can we create a custom jsf component to create commandLink. Check if form exists on page. If yes, do not add form. If no, add form around commandLink.
As a rule, do not put h:form tags in your JSF components. The h:form tag should wrap the component in the page you're using it, not in the component itself. That way you'll be able to mix them with other components in the same form providing you much more flexibility, at the little price of having two more lines of code. That's how is done in all the public component libraries, take a look to Primefaces as an example.
Apart from that, bear in mind that h:commandLink fires a POST request to the server, while you seem to be talking about plain links. In general, h:commandLink is used when you don't know the destination url at the time the view renders. I would suggest to avoid its use for any other case, because still you've got h:link for JSF destinations and h:outputLink for external destinations, you could even use a plain HTML anchor element. And, definitely, firing a GET request doesn't require a h:form tag.
See also:
"This link is deactivated, because it is not embedded in a JSF form."

Piranha CMS existing models and Piranha Menu

I cannot seem to figure out how to add my preexisting pages to the auto navigation menu that Piranha generates when I call #UI.Menu().
Currently, I am using the method described here under Getting the Models to pull CMS content and display it above my model data. I can successfully render the page with Piranha content, but I'm not sure how I can have this page display in the top navigation.
Alternatively, I can pull my data and display the CMS content by creating a new page type, but this means the page type is only ever used to display this single page. It shows up in the navigation generated by #UI.Menu(), but if I continue using this method, I would need to create an additional piranha controller for every Action.
My main objective is adding CMS functionality to my custom MVC project and have everything display in an automatically generated navigation with #UI.Menu().
If you want to add pages in the menu that aren't really controlled by the CMS add a single page type for them, for example "Application Page". Then check the documentation for page types under section 2.5 here http://piranhacms.org/docs/pages/page-types.
If you check the checkbox to allow pages to change the route you can specify the route on each page of this page type. This means you can add your application pages into the structure and the add the route to your controller/action.

sharepoint how to add code handler for button click

I have a SharePoint publishing page. I added a server button via SPD, assign the OnClick handler to btnSubscribe_Click. The question is, how and where can I add codes for this handler? If I have it inside a dll, how can I relate the SharePoint page to the .cs file?
You cannot add controls to publishing pages with SPD, I assume you mean you have added the button to the page layout? or master page?
To make an onclick work, as you know, you need to have a code behind, or script in code.
1) To make the code behind work, you need to make a custom page layout class, extend from Microsoft.SharePoint.Publishing.PublishingLayoutPage
Then change your page layout declaration to use your new page layout code:
<%# Page language="C#" Inherits="Microsoft.SharePoint.Publishing.PublishingLayoutPage,Microsoft.SharePoint.Publishing,Version=12.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c" %>
2) Or you can enable inline script through web.config, and have standard <script runat=server> sections
3) Or better yet, write a web part or a control that will do your subscribe action. And add that to your page layout.

ASP.NET MVC ContentPlaceHolders out of order?

I added a new ContentPlaceHolder (HeadContent) right below the Title so that I can add page-specific css and js files. But when I create a new View using the master page, it puts the default text of the page layout to have the HeadContent open/close tags at the end of the page. Unfortunately, I visually just see it as the first, second and third tags and start typing in my page's html into the last tag. But this isn't the BodyContent place holder because it is the second one. I have to go back and copy/paste them into the correct place. Ugh. Just for kicks, I scrambled all the tags around in the master page just to see what would happen in the view. Sure enough, VS.NET ignores their order in the master page and reorders them the same way everytime.
Why isn't VS just ordering the place holder tags in the same order as in my master page? Actually, how do I make it stop and just do it in the order I have in my master page?
What visual studio is doing (I assume) is loading the MVC View Content Template. I assume the reason all the contents are out of order from your master page is that Visual Studio Extensiblity loads the template then adds any ContentPlaceHolders that are not in the template after the template data.
You can see what the templates look like by going to your Visual Studio file in your Program files then goto Common7\IDE\ItemTemplates\CSharp\Web\MVC2.
There is also a folder for VB. In any case you can open the zip files located in that directory and drill down till you get to the .aspx page and you'll see what VS is inserting into your project when you do a Add New/View.

Resources