How to WelCome control in Webpart code? - asp.net

I need to place a webpart on the page. The webpart need to change Welcome control title. I need to change "WelCome UserName" to "UserName".
I tried http://www.wictorwilen.se/Post/Having-fun-with-the-SharePoint-Welcomeascx-control.aspx , But it did not worked in Webpart. If anybody have idea to change this control. Please share with me.

That article is a pretty comprehensive walkthrough of one way to do this - perhaps your focus should be to determine where you have gone wrong in the implementation of it?
An alternative (hacky) method would be to put some javscript into the page using a CEWP or modifying the master page that will search for the welcome string and remove it.
Hint - don't search for "Welcome", search for its container which looks a little like this (some attributes stripped out for clarity
<span title="Open Menu">
<div id="zz7_Menu_t" ...
class="ms-SPLink ms-SpLinkButtonInActive" >
<a accesskey="L" id="zz7_Menu" ... href="#" serverclientid="zz7_Menu"
menutokenvalues="MENUCLIENTID=zz7_Menu,
TEMPLATECLIENTID=zz3_ID_PersonalActionMenu">
Welcome UserName
</a>
</div>
</span>
Some links to get you started
http://www.dlocc.com/articles/style-a-page-using-the-content-editor-web-part-and-css/
http://www.cleverworkarounds.com/2008/02/28/more-sharepoint-branding-customisation-using-javascript-part-2/
http://blog.pathtosharepoint.com/2008/08/10/the-content-editor-web-part/

Related

add button is missing for Content:Toolbar

The add button that appears over the 2sxc items is missing all of a sudden. It was there a couple days agao but now when I log into any portal in my DNN instance the "+" or add button is missing
here is a screen shot:
As you can see, the change layout and edit buttons are there. Not sure why the add button disappeared.
This is true for apps that I import from the 2sxc.org website as well. So I know its not just my template becasue it also happens on all the apps I have created which use different templates.
But to be thorough, here is my template code, its token based:
<div class="kr-gallery animation">
<p>Hover or touch image and click brush icon for more details</p>
<div class="isotope_grid isotope_grid2">
<div class="isotope_main animation" data-min-width="230">
<repeat repeat="Content in Data:Default">
<div class="isotope_item kr-gallery-item sc-element">[Content:Toolbar]
<div class="photo"><a href="[Tab:FullUrl]/details/[Content:EntityId]"> <img alt="" src="[Content:Image]?h=500" />
<span class="fa fa-paint-brush"></span></a>
</div>
</div>
</repeat>
</div>
</div>
</div>
Any idea why this is?
UPDATE:
Here is my visual query:
SOLUTION:
Based on answer, I switched to razor because I am using a custom query. Here is my simple template code now:
#* this will show an "add" button if the current user is an editor *#
#Edit.Toolbar(actions: "new", contentType: "Image")
#{
// get all images as delived from the standard query
var images = AsDynamic(Data["Default"]);
}
<div class="kr-gallery animation">
<p>Hover or touch image and click brush icon for more details</p>
<div class="isotope_grid isotope_grid2">
<div class="isotope_main animation" data-min-width="230">
#foreach(var img in images)
{
<div class="isotope_item kr-gallery-item sc-element">#img.Toolbar
<div class="photo"><a href="#Link.To(parameters: "details=" + img.EntityId)"> <img alt="#img.Title" src="#img.Image?h=500" />
<span class="fa fa-paint-brush"></span></a>
</div>
</div>
}
</div>
</div>
</div>
The missing + is by design, because editors are used to the + adding an item right after the previous one. This behavior cannot be guaranteed with a query, as the order of things is determined by the query. It is even possible, that adding an item will not show up, if a query-parameter hides that item.
So the design pattern is to provide a separate + button. The easiest way is in razor, I believe the code is something like
#Edit.Toolbar(actions: "new", contentType: "your-content-type-name")
In Tokens it's a bit more messy, and you cannot conditionally check if a user has edit-permissions.
So I recommend you go the edit.toolbar way
You can also find an example of this in the blog app: http://2sxc.org/en/apps/app/dnn-blog-app-for-dnn-dotnetnuke
I could be wrong but did you recently experiment with the visual query designer? Because this could be the cause.
The most common reason is when you use a pipeline (visual query) to deliver data to a template, which is not assigned to this instance. Reason is that "add" in a instance-list of items add it to a specific position (like right after the first one). This isn't the same when you use data like a data base - as there is no sorting in that scenario. So if this is the cause, I'll help you more.

Setting javascript function for all <a>

I have a lightbox script that Im using:
<a class="lb-image-link" href="images/image-1.jpg" data-lightbox="lb-set">
<img class="lb-image" src="images/thumb-image-1.jpg" width="150" height="150"/></a>
But for my clients sake to use CMS software I need to make the data-lightbox="lb-set" function work for all <a> tag on the page or to make it work as a class somehow if possible.
The page is HTML, how can I make this work? Im guessing I need to create javascript for this. Any help is greatly appreciated, thank you
One way would be to learn some jquery, if you are not already familiar with it
http://jquery.com/
and then you can easily attach a function to all click events on every a tag on the page with something like:
$("a").click(function(event) {
//your lighbox code goes here ...
});
EDIT
With the lightbox2 script you are using it doesn't look like there is a way to assign it to a group of links on your page based on class or tag type, so the above function is not relevant. At a quick glance, if you stick with that script the only way to have it work on multiple links on the same page is to include a unique data-lightbox="" attribute in each link, eg.
image #1
image #2
image #3
There are other lightbox scripts that allow you to set the lightbox based on tag type or class, for instance http://fancyapps.com/fancybox/ allows you to do the following:
<a class="fancybox" rel="group" href="big_image_1.jpg">image #1</a>
<a class="fancybox" rel="group" href="big_image_2.jpg">image #2</a>
and then use the script
<script type="text/javascript">
$(document).ready(function() {
$(".fancybox").fancybox();
});
</script>
the above essentially attaches the fancybox lightbox to anything that has a class="fancybox"
Not sure if that helps - there may not be much difference for you having to add a unique data-lightbox="image-3" to each link as apposed to adding a standard class to them :-)
Glen

Nested application and absolute path of html tags

The deal is that when you have the following on your site it works:
Click Me!
But the above fails to work if that site is a nested application.
I have seen two solutions to this opportunity in asp.net.
The first solution that I found was to add the following:
<a runat="server" href="~/Some/Path/file.aspx" class="button">Click Me!</a>
I have not tried this because I feel it would add more crap to your view state.
The solution that I have tried is:
Click Me!
The question is, what is the preferred method of addressing paths in nested applications?
You want to use HyperLink server control. It is meant for that kind of thing.
<asp:HyperLink runat="server" ID="HyperLink1"
NavigateUrl="~/Some/Path/file.aspx"
CssClass="button">Click Me!</asp:HyperLink>
Render as
<a id="HyperLink1" class="button" href="/Some/Path/file.aspx">Click Me1</a>
ASP.Net HyperLink control uses ResolveClientUrl to resolve the given url, so you do not need to do anything.

Image Hyperlink in ASP.NET - MVC 4

I try to create a project for the first time in asp.net (mvc4).
and what i try to do is to create a image which is a hyperlink to go to the index page.
i have search a lot of things and it shows very simple to do that.
but i can´t understand why it doesn´t work for me.
someone can give a hand?
Code:
<a href="<%= Url.Action("Index","Home")%><img src="~/Content/imagens/nav-arrow-back.png"/></a>
The Action is "Index" in the controller calls Home.
you miss a quote
<a href="<%=Url.Action("Index","Home")%>"> ...
^
about this quote you missed
For bad request, fix the whole <img> part
<img src="<%=Url.Content("~/Content/imagens/nav-arrow-back.png")%>"/>
First up, as previously noted you're missing a closing quote on that href. Second, MVC 4 doesn't use the <% %> syntax, at least not by default; it should be using Razor v2 which uses #, so your code should look like this:
<img src="~/Content/imagens/nav-arrow-back.png"/>
If you use the old syntax I assume it would try to handle the actual text <%= Url.Action("Index","Home")%> as a URL, which clearly won't work.

use asp:LinkButton in umbraco

im creating a umbraco plugin, which uses an asp:LinkButton. which looks something like this
<asp:LinkButton ID="ObjectInformationBtn" class="link" runat="server" Text="View Full Details of Item" OnClick="ObjectInformationBtn_Click"></asp:LinkButton>
when I test this plugin locally I get the following result
View Full Details of Item
however when I put the plugin on the website I get a complete different results, which looks like this
<p> </p>
can someone please tell me what is going on.
Are you sure the ascx containing the linkbutton is published to the production website in the usercontrols folder?
Do you have a Macro created that references the User Control that contains the LinkButton?

Resources