I am trying to add Tweet buttons to a few ASP.NET websites by using the documentation here. My code is very simple; I am just adding this to my web pages:
Tweet
<script>!function (d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (!d.getElementById(id)) { js = d.createElement(s); js.id = id; js.src = "//platform.twitter.com/widgets.js"; fjs.parentNode.insertBefore(js, fjs); } } (document, "script", "twitter-wjs");</script>
When I run it, the Twitter pop-up window works fine, but my page's URL, which is supposed to be captured in order to be shared, does not appear. In other words, I only get something like:
Welcome to ConML! #ConML
I must say that I am putting the Twitter code in ASCX user controls and master pages, rather than regular ASPX pages. I am not sure whether this makes a difference. Twitter's developers web site appears to contain no reference to this, and Google hasn't helped much either.
Edit. I just found out that this problem only occurs when working from Visual Studio on my development machine. Once I deploy the website and I navigate to it using a regular browser, the Tweet button works fine. Still, why does it fail in development mode?
Suggestions are welcome. Thanks.
Related
I am trying to use a WebBrowser in a .cs class in a Web Application - NOT A WINDOWS FORM app using (VS 2019).
I know it's a Windows Form app control, but it seems like I should be able to use it in a Web App.
Using WebBrowser in Web App does not have the .Url property, so I just use the .Navigate directly - this is where the code breaks.
I have tried many suggestions on the Net, but nothing seems to work - it looks like most of the examples uses a Web Page - I want to use the WebBrowser directly in code (.cs class).
private static void LoginViaUserAgentFlow()
{
Thread thread = new Thread(delegate ()
{
StringBuilder sb = new StringBuilder(String.Format("{0}/services/oauth2/authorize",
RHOutlook.chosenInstance.sfdcURL));
sb.Append("?response_type=token");
sb.Append(String.Format("&client_id={0}", RHOutlook.chosenInstance.clientId));
sb.Append(String.Format("&redirect_uri={0}", System.Web.HttpUtility.UrlEncode(RHOutlook.chosenInstance.redirectUri)));
WebBrowser webBrowserSFDCLogin = new WebBrowser();
//Here I can't use the .Url becaue it is not available - so I just use
//Navigate to get to the site
webBrowserSFDCLogin.Url = new Uri(sb.ToString());
//This is were it breaks, comes back with error when I navigate to the site.
webBrowserSFDCLogin.Navigate(sb.ToString());
//This code is never reached - failed at above code.
if (webBrowserSFDCLogin.LocationURL != null && webBrowserSFDCLogin.LocationURL.StartsWith(RHOutlook.chosenInstance.redirectUri))
{
//webBrowserSFDCLogin.ScriptErrorsSuppressed = true;
webBrowserSFDCLogin.Stop();
}
});
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
thread.Join();
}
I expect to be able to navigate to the external website. If I can navigate to the site if I copy the url directly in a browser (say Chrome).
I tried using ; this gives me the Url property, but still get the error.
You really should stick to suggestions and examples.
What you are trying to do is to use class that is designed for Windows Application inside a Web Application.
Those two frameworks are similar like Earth and Mars. I am afraid you are not going to be able to grow a tree on Mars.
How can I reload facebook page element, in one page application?
https://developers.facebook.com/docs/plugins/page-plugin
If I delete facebook embedded div from DOM and add this div again, facebook plugin won't automatically reinit. I'm guessing I have to do extra javascript work, to tell plugin to reinit.
Im using code that loads facebook plugin.
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_GB/sdk.js#xfbml=1&version=v2.4&appId=xxx";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
Then on home dynamic tab I'm using code to embed facebook page on my one-page app:
<div class="fb-page" data-href="https://www.facebook.com/facebook" data-small-header="false" data-adapt-container-width="true" data-hide-cover="false" data-show-facepile="true" data-show-posts="true"><div class="fb-xfbml-parse-ignore"><blockquote cite="https://www.facebook.com/facebook">Facebook</blockquote></div></div>
It loads ok at the first time, I can see embeded facebook page. But if I will change tab, and change back to home again, the facebook code doesn't execute and I can't see facebook page anymore.
At this point how can manually reload Facebook embedded page ?
Call the following JS code
FB.XFBML.parse();
after a new content loads to make the Facebook SDK reload each
<div class="fb-page" data-href="https://www.facebook.com/facebook" data-small-header="false" data-adapt-container-width="true" data-hide-cover="false" data-show-facepile="true" data-show-posts="true"><div class="fb-xfbml-parse-ignore"><blockquote cite="https://www.facebook.com/facebook">Facebook</blockquote></div></div>
tag on the page. If you need to reload a Facebook plugins only in a certain DOM element, pass it as argument to the function:
FB.XFBML.parse(document.getElementByID('certain-plugins-holder'));
Full reference: https://developers.facebook.com/docs/reference/javascript/FB.XFBML.parse
What I did was move the
<div class="fb-page" data-href="https://www.facebook.com/facebook" data-small-header="false" data-adapt-container-width="true" data-hide-cover="false" data-show-facepile="true" data-show-posts="true"><div class="fb-xfbml-parse-ignore"><blockquote cite="https://www.facebook.com/facebook">Facebook</blockquote></div></div>
To a hidden div at the end of the document. Once facebook loads it then I use javascript to clone the element to where I need it to be. This example uses jQuery. Anywhere I need the page plugin to show up I placed a
<div id="facebook-timeline"></div>
Then in the javascript that loads the page or section dynamically I run the script below
$('.fb-page').clone(true).replaceAll('#facebook-timeline');
I have installed the ShareThis module in Drupal 7 on my site, but when I reload my pages, the buttons disappear. There seems to be information on the Drupal forums that explain how to fix this issue with javascript, but I'm unclear which file to put the code in.
http://drupal.org/node/1197104#comment-6636050
http://drupal.org/node/322808#comment-7357744
(p.s. I'm not using the Views module)
If it is issue of JavaScript or ajax then below solution work perfectly.See below code. this code add in JavaScript file(theme or module).
Drupal.behaviors.my_custom_behavior = {
attach: function (context, settings) {
var url = window.location.href;
var urls = url.split('/').pop().split('.').shift();
if (urls == 'abc') {
stButtons.locateElements();
}
};
};
Note: Above example is only particular page.if want to use it globally remove if condition.
What is the best way to go about disabling the cache in google chrome for mac, so that when I am developing a flash application, it will bring in the new movie every time?
Please advise, I can't figure out how to ensure the version of the .swf I am looking at is the most recent version.
One solution might be to get the flex compiler to append a timestamp to the .swf filenames, is this possible?
Thanks!
Go to the 'View' menu, open Developer Tools. In the bottom right corner of the Developer Tools is a gear icon. Click it, then check the 'Disable Cache' checkbox.
In your embed code where ever you the swf file you have to put a random number or a time stamp of some sort on the query. Whenever there is a query string that changes the browser will not cache the page.
"MySWFName.swf?t=" + new Date().getTime();
Best method would be to embed your SWF using SWFObject with this code.
In the html body tag do this.
<body onLoad="loaded()" onunload"doUnload( )">
<div id="replaceMe">Loading content.</div>
</body>
and for the javascript do this ( obviously changing the stuff wrapped in { } to your needs
<script type="text/javascript" src="swfobject.js">
<script type="text/javascript">
function loaded() {
var flashvars={}, params={}, attributes={}, tmp, version, width, height, container, flashObj;
flashvars.userName = "testvar";
params.menu = "true";
params.quality = "high";
params.bgcolor = "${bgcolor}";
params.allowscriptaccess = "always";
params.allownetworking = "all";
attributes.id = "${application}";
attributes.name = "${application}";
attributes.align = "middle";
attributes.allowscriptaccess = "always";
attributes.allownetworking = "all";
tmp = "expressInstall.swf";
version = "${version_major}.${version_minor}.${version_revision}";
width = "${width}";
height = "${height}";
container = "replaceMe";
flashObj = "${swf}.swf?t=" + new Date().getTime();
swfobject.embedSWF(flashObj, container, width, height, version, tmp, flashvars, params, attributes);
}
</script>
Don't forget to add a copy of SWFobject
You will never have caching issues again
EDIT:
BTW if you replace your code in your html.template.html file with this code it will generate the values for you. :)
Personally, I would never do that. Caching is there for a reason and shouldn't be disabled when you're running it locally. In my experience, the best way to do it is have a 'version' (normally a static properly in a Class) number increment every time you build (by using Ant or Maven; even better if you have an automation engine to do it too) which then attached that version number as a url parameter for the flash movie like Movie.swf?version=1.31 in the html.
I'm using ssrs with an asp.net reportviewer control to display server reports. We want to do away with the toolbar because it doesn't fit with our look and feel but we want to maintain some of the functionality, the one bit I'm struggling with is the print. Is there any way to bring up the same print dialog as the print button on that toolbar from the asp.net page?
http://msdn.microsoft.com/en-us/library/ms252091(v=VS.80).aspx
Is the closest that I’ve found, however I’m not using local reports (so it would make sense if there was a built in function around somewhere), and it skips the printer dialog portion which is unacceptable. I don’t believe that I can actually call the winforms printdialog on an asp.net page, but it’s not something I’ve tried.
Any help would be much appreciated.
Here is a script to bring up the print dialog:
<script language="javascript">
function PrintReport() {
var viewerReference = $find("ReportViewer1");
var stillonLoadState = clientViewer.get_isLoading();
if (!stillonLoadState ) {
var reportArea = viewerReference .get_reportAreaContentType();
if (reportArea == Microsoft.Reporting.WebFormsClient.ReportAreaContent.ReportPage) {
$find("ReportViewer1").invokePrintDialog();
}
}
}
</script>
To invoke, just call PrintReport()
Detailed explanation here:
http://blogs.msdn.com/b/selvar/archive/2011/04/09/invoking-the-print-dialog-for-report-viewer-2010-control-using-the-javascript-api.aspx