It is really simple. Jeroen has already posted the code you need. You then only to copy the DLL containing the codebehind into the "bin" folder of your installation and the *.ascx file into the "usercontrols" folder of your installation.
In the umbraco backend navigate to the developer section, right click on the "Data Types" folder and create a new datatype. Selection the "umbraco usercontrol wrapper" as Property editor. Save the data type and the select your deployed ASCX file from the usercontrol dropdown. Save again and you have successfully created your first own data type.
Be sure to also select the correct database datatype and ensure value object you return maps this datatype.
Managed to get it working. Another thing for the below, how do I get the value of the "Link to document" to be used below? (the parts below with the comment)
Thanks
publicpartialclassHyperLinkView:UserControl, umbraco.editorControls.userControlGrapper.IUsercontrolDataEditor { #region IUsercontrolDataEditor Members
publicobject value { get { returnHplClick.NavigateUrl; } set { if((value !=null)&&(!string.IsNullOrEmpty(value.ToString()))) { HplClick.NavigateUrl= value.ToString(); HplClick.Text= value.ToString(); HplClick.Target="_blank"; } } }
#endregion
protectedvoidPage_Load(object sender,EventArgs e) { value = "/TestTemplate/"; // how do I get the value of the 'Link to document' here to concat with the "/TestTemplate/"? } }
I suggest to override the onload method (or even page_load, but I always preferec the control specific methods) and reading the value on postback. Use a private member value to store the value in background instead of directly referencing your web control.
public YourClass : .... { private int _linkValue;
public object value { get { return _linkValue; } set { if (value != null && !string.IsNullOrEmpty(value.ToString())) { _linkValue = value.ToString(); } } }
Property similar to "Link to document"
Hi,
I need to create a new property which will display exactly what is shown by the "Link to document" and with additional text at the end.
Eg
Link to document showing - www.test.com/here/
New property needs to show - www.test.com/here/?alttemplate=theTemplate
Will it be possible to create such property?
thanks
Yes you could create a new datatype which does this. Here is an example to get you started (with the usercontrol wrapper):
This is a bit like the label datatype, but as a hyperlink.
Jeroen
I'm kind of new on the usercontrol thingy.
Any guide onto where or how should I start?
Thanks
It is really simple. Jeroen has already posted the code you need. You then only to copy the DLL containing the codebehind into the "bin" folder of your installation and the *.ascx file into the "usercontrols" folder of your installation.
In the umbraco backend navigate to the developer section, right click on the "Data Types" folder and create a new datatype. Selection the "umbraco usercontrol wrapper" as Property editor. Save the data type and the select your deployed ASCX file from the usercontrol dropdown. Save again and you have successfully created your first own data type.
Be sure to also select the correct database datatype and ensure value object you return maps this datatype.
Managed to get it working. Another thing for the below, how do I get the value of the "Link to document"
to be used below? (the parts below with the comment)
Thanks
I suggest to override the onload method (or even page_load, but I always preferec the control specific methods) and reading the value on postback. Use a private member value to store the value in background instead of directly referencing your web control.
If this is what you want ;-)
how do I get the value from the "Link to document"?
If the node is published you could try something like this (might need to add some namespaces)
Jeroen
The below error came out
Error2The type or namespace name 'Node' could not be found (are you missing a using directive or an assembly reference?)
You need to add a reference to the umbraco.dll file and than Visual Studio can resolve it for you.
Jeroen
Kind of new in this thing, how can I add a reference to the umbraco.dll file in Visual Studio?
This video might help :) http://umbraco.com/help-and-support/video-tutorials/introduction-to-umbraco/developer-introduction/using-net-user-controls/TVPlayer
Jeroen
I suggest using the nuget package manager. And the run Install-Package UmbracoCms.Core
Verify to get the correct version you are corrently deploying to.
still can't figure out how to get it work.
any other way that I can get the CurrentPage's Url in the .ascx.cs file?
You'll need the reference to the umbraco.dll file which is in the /bin folder of you website. Maybe this can help: http://msdn.microsoft.com/en-us/library/wkze6zky(v=vs.80).aspx
Jeroen
good news, managed to get it all sorted out :)
is working on a reply...