I am using c#.net.
I am trying to create a LinkButton within the code-behind, when I debug my code I recieve no errors, however its not accessing the EventArg attached to the button, it does however refresh the page. What am I doing wrong?
Button Code
LinkButton myLinkButton = new LinkButton();
myLinkButton.ID = appointment.appID.ToString();
myLinkButton.CommandArgument = appointment.appID.ToString();
myLinkButton.Command += new CommandEventHandler(ViewClick);
myLinkButton.CommandName = appointment.appID.ToString();
myLinkButton.Text = appointment.contactName
Used to style button
string divLook = "height:" + divHeight + "em";
Button is then added to a panel
Panel p = new Panel();
p.Style.Add("linkStyle", divLook);
p.CssClass = "standardLink";
p.Controls.Add(myLinkButton);
dataCell.Controls.Add(p);
protected void ViewClick(object sender, CommandEventArgs e)
{
var appointmentId = Convert.ToInt32(e.CommandArgument);
Debug.Write("Are you even getting in here");
}
Thanks in advance for any help.
Clare
Everything looks legit. I would recommend viewing the source of the generated page and looking at the ID that the link button is getting. It may be duped on the page.
Related
I have some html content which I'm inserting into a pptx slide and persisting the formatting.
I'm using apache POI for this. A base64 gets generated which I later convert to pptx. Up until now I haven't faced any issues. But now hyperlinks are causing problems.
When I just create the hyperlink with method createHyperlink(), it works fine and the PPT gets generated but the link is not set so it doesn't do any action when clicked.
When I set the URL either through setAddress() or linkToUrl() methods, the PPT generated seems corrupted and windows asks me if it can "repair" it. After the repair option, when the PPT opens, the link does not work.
Below is the code I wrote:
Approach 1:
textRun.createHyperlink();
textRun.getHyperlink().linkToUrl("http://poi.apache.org");
Approach 2:
textRun.createHyperlink();
textRun.getHyperlink().setAddress("http://poi.apache.org");
Approach 3:
XSLFHyperlink link = textRun.createHyperlink();
link.setAddress("http://poi.apache.org");
Approach 4:
XSLFHyperlink link = textRun.createHyperlink();
link.linkToUrl("http://poi.apache.org");
None of these approaches work.
Does anyone have any idea regarding this and provide me the right solution?
Not clear where your problem is. For me XSLFHyperlink.setAddress as well as XSLFHyperlink.linkToUrl are working and create usable hyperlinks using current Apache POI version 5.2.3.
Complete example:
import java.io.FileOutputStream;
import org.apache.poi.xslf.usermodel.*;
import org.apache.poi.sl.usermodel.*;
import java.awt.Rectangle;
public class CreatePPTXTextShapeWithLinkedText {
static XSLFTextParagraph drawRectWithText(XSLFSlide slide, int x, int y, int width, int height, String text) {
XSLFAutoShape shape = slide.createAutoShape();
Rectangle rect = new Rectangle(x, y, width, height);
shape.setAnchor(rect.getBounds2D());
shape.setShapeType(ShapeType.RECT);
shape.setText(text);
shape.setTextDirection(TextShape.TextDirection.HORIZONTAL);
shape.setVerticalAlignment(VerticalAlignment.MIDDLE);
XSLFTextParagraph xslfTextParagraph = shape.getTextParagraphs().get(0);
xslfTextParagraph.setTextAlign(TextParagraph.TextAlign.CENTER);
return xslfTextParagraph;
}
public static void main(String[] args) throws Exception {
SlideShow slideShow = new XMLSlideShow();
XSLFSlide slide = (XSLFSlide)slideShow.createSlide();
XSLFTextParagraph xslfTextParagraph = drawRectWithText(slide, 100, 100, 500, 50, "This is a test text. ");
XSLFTextRun xslfTextRun = xslfTextParagraph.addNewTextRun();
xslfTextRun.setText("This text is linked to Apache POI.");
XSLFHyperlink xslfHyperlink = xslfTextRun.createHyperlink();
xslfHyperlink.setAddress("http://poi.apache.org");
xslfTextRun = xslfTextParagraph.addNewTextRun();
xslfTextRun.setText(" This is a test text again. ");
xslfTextRun = xslfTextParagraph.addNewTextRun();
xslfTextRun.setText("This text is linked to Stackoverflow.");
xslfHyperlink = xslfTextRun.createHyperlink();
xslfHyperlink.linkToUrl("https://stackoverflow.com");
xslfTextRun = xslfTextParagraph.addNewTextRun();
xslfTextRun.setText(" This is a test text again. ");
FileOutputStream out = new FileOutputStream("./CreatePPTXTextShapeWithLinkedText.pptx");
slideShow.write(out);
out.close();
slideShow.close();
}
}
It creates:
Note: To open a hyperlink while editing a presentation, right-click the hyperlink and select Open Hyperlink on the shortcut menu. Only during a slide show hyperlinks will work as you might think they should. See Open a hyperlink. But that's by design in PowerPoint.
I am in the process of creating an interactive map which gives users the option of clicking on a random site, viewing the content and then either going back to the overview, or continuing on to the next site.
I am having trouble adding 1 to the site number, when the users click "next site". Instead of continuing on to the next site, it goes on from a random number.
My code for the view site button
vmsite1.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandlervmsite1);
function mouseDownHandlervmsite1(event:MouseEvent):void
{
gotoAndStop(33); // WHERE THE DYNAMIC CONTENT LOADS
var siteNumber = 1;
}
My code for the next button:
next_site1.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandlernext_site1);
function mouseDownHandlernext_site1(event:MouseEvent):void
{
siteNumber = siteNumber;
if (siteNumber <= 29) {
siteNumber ++;
}
else {
siteNumber = siteNumber;
}
// UNLOAD THE PREVIOUS SLIDE SHOW
myLoader.unload();
SiteNumberText1.text = siteNumber.toString();
site1scroll.scrollTarget = field;
loadData();
// LOAD THE SLIDE SHOW
var urlforswfcomp2:URLRequest = new URLRequest(URLSWF + siteNumber + imgext);
myLoader.load(urlforswfcomp2);
}
I have had a look through the AS3 guide on the Adobe website, but I can't find an issue similar to mine.
http://help.adobe.com/en_US/ActionScript/3.0_ProgrammingAS3/WS5b3ccc516d4fbf351e63e3d118a9b90204-7fcf.html
http://www.adobe.com/devnet/actionscript/learning/as3-fundamentals/operators.html
Thanks in Advance!
I moved my siteNumber variable definition outside the button code, and it worked. This is my new view more button code.
var siteNumber:int = 0;
vmsite1.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandlervmsite1);
function mouseDownHandlervmsite1(event:MouseEvent):void
{
gotoAndStop(33);
siteNumber = 1
}
I'm using primefaces tagcloud. But when i clicked on the links given on the tagcloud, it opened in that same window.But on clicking the tagcloud links it should open in a new window not on the same window.
I want a new window will open when i click on the tagcloud links.
Can anyone please help me about this topics ???
JavaScript solution:
One possible approach could be JavaScript:
<p:tagCloud model="#{tagCloudBean.model}" onclick="preventDefault(event)">
<p:ajax event="select" update="msg" listener="#{tagCloudBean.onSelect}" />
</p:tagCloud>
onclick triggers a JavaScript function which prevents the link from getting opened.
function preventDefault(e) {
e.preventDefault();
}
Also, by adding an ajax event you can call a listener in your managed bean.
public void onSelect(SelectEvent event) {
TagCloudItem item = (TagCloudItem) event.getObject();
String url = item.getUrl();
String script = "window.open('" + url + "');"
RequestContext.getCurrentInstance().execute(script);
}
There you can access the url of the TagCloudItem and execute a JavaScript statement which should open a new browser window.
This possible solution is untested, but just give it a try.
I have a requirement where I need to remove or hide the default links displayed in Suite Bar like NewsFeed, SkyDrive, Sites etc. I want to add my own links and use this section as my Menu.
So while adding I want the items to be easily configurable by content editors. They can edit the links that needs to be shown and control the order. No hard coding of links.
If someone can help in this.
Regards,
navish
This can be done by oevrriding Delegate controls that displays these links. The below links will help
http://www.learningsharepoint.com/2013/02/10/addremove-links-in-top-suitebar-skydrivesitesnewsfeed-in-sharepoint-2013/
You should create a custom delegate control that target the SuiteLinksDelegate ControlId.
Add it to a Farm-scoped feature to make the custom delegate control active in the whole farm.
If you do not like hard-coded links you can program against a custom SharePoint list that stores the configurable links.
To Add custom links you can use the approach described here: http://zimmergren.net/technical/sp-2013-some-new-delegatecontrol-additions-to-the-sharepoint-2013-master-pages
If you need to remove some built-in links while keeping others (I had this requirement) you can use code like this:
public partial class SuiteLinksDelegate : MySuiteLinksUserControl
{
protected override void Render(HtmlTextWriter writer)
{
// save for later
var httpwriter = (writer.InnerWriter as HttpWriter);
// hijack the innerwriter
var sb = new StringBuilder();
var sw = new StringWriter(sb);
var tw = new HtmlTextWriter(sw);
writer.InnerWriter = tw;
// call base
base.Render(writer);
// get the html
var currentHtml = sb.ToString();
XElement element = XElement.Parse(currentHtml);
// remove SkyDrive link
var suiteLinkNodes = element.Elements("li").ToArray();
var remainingNodes = suiteLinkNodes.Where(node => !(node.ToString().Contains("ShellDocuments")));
element.ReplaceNodes(remainingNodes);
var modifiedHTML = element.ToString();
// set back the old innerwriter
writer.InnerWriter = httpwriter;
// write delegate control html
httpwriter.Write(modifiedHTML);
}
}
You can use javascript approach to hide this links as described in below link
http://www.tuyrcorp.com/sharepoint-2013-top-links-name-id-and-how-to-hide-them/
you can also add new item in the dropdown using this same javascript as well
Hope this helps
Thanks
I'm using the SC HTML5 player, when one sound finishes, I load in another source, however the FINISH event only seems to fire for the first song, my code is as follows
//Set the source
document.getElementById("sc-widget").src = scPath;
//get the widget reference
var widgetIframe = document.getElementById('sc-widget'),
widget = SC.Widget(widgetIframe);
//set the finish event
widget.bind(SC.Widget.Events.FINISH, endSC);
function endSC() {
var scPath = "http://w.soundcloud.com/player/?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F1848538&show_artwork=true&auto_play=true";
document.getElementById("sc-widget").src = scPath;
var widgetIframe = document.getElementById('sc-widget'),
widget = SC.Widget(widgetIframe);
widget.bind(SC.Widget.Events.FINISH, endSC);
}
I've tried setting the endSC target to another function but that doesn't work, what am I missing? Thanks!
I had the same problem. SC.Widget method is working fine when I call it for the first time, but if I try to call it for the second time the console will fire "Uncaught TypeError: Cannot read property 'parentWindow' of null" error in http://w.soundcloud.com/player/api.js script. And that is where api.js script stops with actions (.Widget, .bind, etc.)
I found the solution. It's very weird, but it is a solution.
SoundCloud remote script is minified. Load it in your browser, C/P it in some online js beautifier and save it locally. Edit line 103 as follows:
return a.contentWindow;// || a.contentDocument.parentWindow
So I removed that .parentWindow call.
Save the file and call it in your page's head section. And that's it! Now FINISH event fires on every loaded widget.
I hope this will help.
Looks like this question is over 10 years old, but it just came up for me now.
I recreated the iframe div from scratch. Otherwise, the SC.Widget.Events.FINISH will only fire when the original embed player finishes.
You must reset the DOM element events by completely recreating the iframe element, like so:
//EXAMPLE SC SONG IDs
let songIds = [216109050, 779324239, 130928732]
let incrementingIndex = 0
function playSongsInIframe() {
let iframeParent = document.querySelector('#sound-player')
let iframeElement = document.querySelector('#sound-player iframe')
iframeElement.remove()
//CODE TO ADD NEW SOUND IDs
//yourSoundId = songIds[incrementingIndex]
let newIframe = document.createElement('iframe')
newIframe.id = "sound-" + yourSoundId
newIframe.width = "100%"
newIframe.height = "166"
newIframe.scrolling="no"
newIframe.frameborder="no"
newIframe.allow = "autoplay"
newIframe.src = "https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/" + yourSoundId + "&auto_play=true"
iframeParent.appendChild(newIframe)
let widget = SC.Widget("sound-" + yourSoundId);
widget.bind(SC.Widget.Events.READY, () => {
console.log('Ready...');
widget.play()
});
widget.bind(SC.Widget.Events.FINISH, () => {
console.log('Song ended...');
incrementingIndex++
playSongsInIframe()
});
}
One last consideration - this process must be started from a user event, like a click. You can add this function to the onclick attribute of an HTML button element:
<button onclick="playSongsInIframe()">Start Radio</button>