How to do a 'HTTP-POST' with HyperlinkButton - silverlight

I have a silverlight application where users can type in a SQL-query in the application, then the server returns the query result as an Excel file.
Users click on a download link, which is linked to a HttpHandler in the server which generates the excel file. After some research[1] I found out that using the HyperlinkButton control is the most robust way of providing links to file without the hassles of browser's popup security settings.
I need to send the SQL query, which can get quite long, as a parameter to the HttpHandler.
I can't include it in the url as querystrings(HTTP GET) due to size limitations.
Is there a way to do a 'HTTP-POST' with HyperlinkButton?
[1] Browser.HtmlPage.Window.Navigate is blocked but HyperlinkButton isn't - why?

In that case I think you can try sending a get/post request using jquery.
Post request API documentaton: http://api.jquery.com/jQuery.post/
Get Request API documantation: http://api.jquery.com/jQuery.get/
<!DOCTYPE html>
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js">
</script>
<script>
function f(){
$.post("http://www.w3schools.com/jquery/demo_test_post.asp",
{
name:"Donald Duck",
city:"Duckburg"
},
function(data,status){
alert("Data: " + data + "\nStatus: " + status);
}
)};
</script>
</head>
<body>
Send an HTTP POST request to a page and get the result back
</body>
</html>

Instead of Using Links Why just you make the buttons look like Links instead. One perfect example of buttons been shown as links is the Facebook. It has several number of buttons in a post, but all of them are shown as links. Here is the Css Code that what it makes a button look like a link. You can always change the look and feel of the link(perhaps Button).
Here the css code for the button.
button {
background:none!important;
border:none;
padding:0!important;
/* Do all your Styling to the Button here. It will look like a link instead. */
}
Button HTML Code.
<button>Your Button Here.</button>
Hope that Solves your Problem. Thank You.

Related

window.ATL_JQ_PAGE_PROPS in JQgrid

I want to popup a Jira request popup, on click of an icon. This icon's css class is created in the JQ grid, in the column model. On the click of this icon, I need to open a Jira request popup.
can someone shed some light to achieve this.
EDIT - If you are talking about adding a JIRA issue collector to your own site, then this may help:
Step 1: Create an issue collector within Jira. Its a straight forward process and you can find the steps here or follow these steps:
Login to Jira
Choose > Projects.
On the left of the Project Summary page, click the Issue Collectors tab. The Issue Collectors page is displayed, listing any issue collectors that have already been set up in your project.
Click the Add Issue Collector button to open the Add Issue Collector page.
In the top section of the Add Issue Collector page, fill in the fields provided (name, description, issue type, issue reporter, match reporter, collector browser info)
In the middle section of the Add Issue Collector page (entitled 'Trigger'), specify the "Trigger text" and "Trigger style".
In the lower section of the Add Issue Collector page (entitled 'Issue Collector Form'), specify the "Template" and "Message".
Click the Submit button to save your changes.
After clicking the Submit button to save your new issue collector, a page containing code snippets is displayed. Use the code and information provided to embed your new issue collector into your web site. This is what the snippets looks like
<script type="text/javascript" src="https://your_jira_url.co.za/s/a08716ba9b893434c0030633c043df94-T/asfxnf/74002/32f7d0e4f4445b0f89b4b03188c6e1bf/2.0.23/_/download/batch/com.atlassian.jira.collector.plugin.jira-issue-collector-plugin:issuecollector/com.atlassian.jira.collector.plugin.jira-issue-collector-plugin:issuecollector.js?locale=en-US&collectorId=*****"></script>
Step 2: Embed code snippet to your site (Add the below code to the html page you want the Jira popup to appear on)
<!-- This is the script for the issue collector feedback form -->
<PASTE CODE SNIPPET HERE>
<!-- This is the script for specifying the custom trigger. -->
<script type="text/javascript">
window.ATL_JQ_PAGE_PROPS = {
"triggerFunction": function(showCollectorDialog) {
//Requries that jQuery is available!
jQuery("#feedback-button").click(function(e) {
e.preventDefault();
showCollectorDialog();
});
}
};
</script>
 
Step 3: Add a trigger to call up the collector popup (same html page as above)
<a href="#" id="feedback-button" class='btn btn-primary btn-large'>Report feedback</a>
When you click the button, your Jira popup will appear.
Reference:
https://confluence.atlassian.com/adminjiraserver071/advanced-use-of-the-jira-issue-collector-802592648.html

Having trouble with implementation

I have spent 2 hours + on the lightbox. I have checked paths to CSS and Javascript. I have used both the included jquery and Google's imported JQuery.
When I click an image it opens a new window with that image larger on a white background. I want it to overlay the current page with <> and x.
You can see an example: http://demopbdesignsource.tierstrategies.com/a.aspx
Thanks
Looking at your code on your page I do not see where you are calling the lightbox.js script - that needs to be called right before the body close tag.
Also lightbox help states : If you already use jQuery on your page, make sure it is loaded before lightbox.js. - ◦Include the Javascript at the bottom of your page before the closing /body tag:
I used the lightbox-plus-jquery.js and called that just before the close of the body tag and it worked. I called the lightbox-plus-jquery.js just before the close of the body tag because it has both jquery and lightbox combined.
I am still working on the page and I am just using html not .net but the lightbox would work the same. If you look at my source you will see the script call right before /body tag.
http://just-in.com/recycledDresser/index.htm
Hope this helps.
Debra W.
You need to call the Lightbox script.
Something like
Placing it in the line before the line works for me.
Both
http://demopbdesignsource.tierstrategies.com/X/LightBox.css
and
http://demopbdesignsource.tierstrategies.com/X/LightBox.js
cannot be found.
The link provided in the question is giving 404 right now.
but I think you just need to follow the steps given at
http://lokeshdhakar.com/projects/lightbox2/
to set up lightbox.
you may have missed either of the following :
Include the CSS at the top of your page in your <head> tag:
<link href="path/to/lightbox.css" rel="stylesheet">
Include the Javascript at the bottom of your page before the closing </body> tag:
<script src="path/to/lightbox.js"></script>

When sharing on facebook, showing angular brackets instead of content

AngularJS rendering the content fine into title and meta tags, but when I share it with facebook or google, in the popup window it shows angular {{ }} there.
Code:
<div ng-controller="MyCtrl">
<title>{{mDetails.display1}} - Subtitle</title>
<meta name="description" content="{{mDetails.display1}} - {{mDetails.address1}} , {{mDetails.city}}, {{mDetails.state}}, {{mDetails.country}}">
.
.
Note: I am already using ng-cloak.
Thanks for help.
Two ways, as mentioned on another question :-
og meta tags, social buttons and angularjs
Method 1 :-
This can't be done using javascript. Some people think that Facebook is reading what's currently on the page. It's not. It makes a separate request to your server using the same url (from window.location.href) using it's Scraper, and the Facebook Scraper does not run javascript. That's why you get {{page_title}} when clicking on something like a Facebook share button. Your content will have to be generated by the server so when Facebook goes to hit the url it gets the content it needs up front without the need for javascript. You can tackle the server side rendering in a fews ways.
You can allow your server side technology to render the content.
You can use the PhantomJS approach https://github.com/steeve/angular-seo.
Method 2 :-
There's also a possibility that you can re-render Facebook widgets. Use their parse method:
FB.XFBML.parse();
after your angular stuff has completed. It's not working for my share button (yet!!), but I tested it on likes, and it's cool. Basically it re-scans the DOM and renders the Facebook widgets. You can also pass it a single element, something like this directive:
'use strict';
angular.module('ngApp')
.directive("fbLike", function($rootScope) {
return function (scope, iElement, iAttrs) {
if (FB && scope.$last) {
FB.XFBML.parse(iElement[0]);
}
};
});
This snippet would rescan the DOM for html5 facebook fb-like widgets when creating the last element in angular repeater.
Another accepted answer in the same context :-
https://stackoverflow.com/a/24086652/1366216
Edit:
I implemented json on server side just for the meta tags, however its an overhead because for on page data, there is still ajax call.
$mid=$_GET['id'];
$mJSON = file_get_contents($homeurl."/json/getdetail.php?mid=".$mid);
$mObject = json_decode($mJSON, true);
if ($mObject['ID'] != undefined && $mObject['ID'] != '') {
<meta property="og:title" content="<?php echo $mObject['display1'];?>"/>
<meta property="og:description" content="<?php echo .$mObject['display2']; ?>"/>
}
A possibility that worked for me is to have a "fallback" for FB description (so it would be a generic description that shows when angular hasn't loaded). I achieved this using two ng-if.
<meta ng-if="mDetails.display1" property="og:title" content="{ mDetails.display1 + "- Subtitle"}}">
<meta ng-if="!mDetails.display1" property="og:title" content="A generic title">
Whenever there are two meta descriptions with the same title, FB will take the last one. And after rendering, googlebot will only see the non-default one.

AngularJS w/ noscript

I am attempting to create a SPA using AngularJS as the main view for my website. I'm using ServiceStack on the server-side and can therefore cleanly serve HTML or JSON requests depending on what's accessing it. My main concern is the use of script blockers, preventing AngularJS from rendering the page properly. So far my main way of working is to render static pages, and inject a small script that redirects to the AngularJS-powered pages if it detects if Javascript is enabled. This works great since every URL works fine when the user begins at the static pages, but I've ran into a couple of snags.
Browsing to a link which includes the "?View=SPA" breaks the page if JavaScript is disabled
This causes the first page loaded to be loaded twice.
I'm looking for an alternative, but so far I haven't found any clean solutions. I was thinking about including the "?View=SPA" as a POST variable, but I'm still iffy on that implementation.
Any thoughts?
Instead of redirecting to an other page, I would implement both cases in the same HTML File as follows:
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js"></script>
<style>.hideIfNoScript {display: none}</style>
</head>
<body ng-app ng-init="msg = 'hello world'">
<input class="hideIfNoScript" ng-model="msg" />
<p class="hideIfNoScript">{{msg}}</p>
<noscript>
<p>Content without javascript</p>
</noscript>
<script type="text/javascript">
var myEl = angular.element( document.querySelectorAll( '.hideIfNoScript' ) );
myEl.removeClass('hideIfNoScript');
</script>
</body>
</html>
The CSS Class hideIfNoScript in the head section makes sure that all HTML Tags with this class are never shown to the user, if javascript is disabled.
The noscript tag shows the alternative content.
If javascript is enabled, the little script at the end of the body section makes those elements visible. And in this case, the contents of the noscript tag are hidden.
Browsing to a link which includes the "?View=SPA" breaks the page if JavaScript is disabled
Hide those links by default:
a[href*='SPA'] { display: none; }
This causes the first page loaded to be loaded twice
Use a cookie on a browser-check page which loads the first page in an iframe or redirects to it to avoid this.
References
Track Non-JavaScript Visits In Google Analytics

How can I insert text from an external file onto a div?

As the title says; I want the content of an external file (text,html,php etc.) onto a div.
There is basically text in an external file, called: text_1.txt or *text_1.html* , and I want that text displayed within a div that is located on a homepage.
The perfect solution would be a pretty basic code to display text from a text or html file
by inserting it onto a div classed: content
Here I have illustrated the issue with basic code, use this as an example to write a solution.
Code in text_1.html:
<p>Hello world.</p>
Code in index.html:
<!doctype html>
<html>
<head>
<title>Homepage</title>
</head>
<body>
<div class="content"></div>
</body>
</html>
This is as simple as I can put it.
I highly appreciate all the answers I receive, thank you.
PS here are some things you should avoid answering:
Use iframes, or any other frame type solution.
Make use of the onclick function within jquery etc.
Use ineffective textfields to replace certain text.
Make usage of an insertion code for virtual server or similar methods.
There's no way to do this unless and until you use Server Side Includes using PHP, ASP, or JSP
http://en.wikipedia.org/wiki/Server_Side_Includes
If you want to do it using php you can use this:
require_once('filename.php'); /* For including files */
Or use native functions to open .txt files in your pages
Why dont you just do it with jquery
$(document).ready(function() {
$('.content').load('text_1.html');
});

Resources