print a popup page - asp.net

I have a dev express calendar . Now, the requirement is that i need to print a particular record. But the problem is that, the record details open in a pop up and i need to print only the popup page. But when i used print on the page it printed the whole page i.e. the pop up and side stuff on the main page.
This is what i did:
<input type="button" value="Print Form" onclick="window.print()" />
So, can u let me know what i need to do to print only the pop up. (excluding page stuff)

Related

Changing the location of Woocommerce coupon code on checkout makes purchase button stop working?

Ok so I have looked everywhere for a solution to this but I can't figure out why this is happening. Logically it makes no sense. I'm not really a coder but I know some basic PHP.
I used the following code to simply move the coupon field in Woo checkout to a different location:
/*** MOVE THE COUPON CODE ***/
remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form', 10 );
add_action( 'woocommerce_after_order_notes', 'woocommerce_checkout_coupon_form' );
After this code is added, the "Buy Now" checkout button to finalize the order does nothing on click, like the JS is disabled.
When the code is removed and coupon code goes back to original location, the button works normally.
Has anyone else had this happen to them? It's so bizarre.
You can see the page (with code above implemented) here:
http://insiders.nomadmoguls.com/payment/?add-to-cart=205479&variation_id=205481&attribute_pa_type-of-pass=yearly
Thanks in advance for everyone's help! This was my last resort after several hours looking for a solution on my own!
The issue is caused by the hook you're using, woocommerce_after_order_notes. It's causing the <form name="checkout"> to close before the Submit button, so the Sign Up Now button isn't actually inside that form anymore, so it can't submit it when it's clicked, since your (paraphrased) markup is like this:
<form name="checkout">
<!-- coupon code stuff -->
</form>
<button type="submit">Sign Up Now</button>
Check out this video of me on the site with Dev Tools open. You can see the Sign Up Now button outside the Checkout form - as soon as I drag it up to be inside the form, it works just fine.
A relatively common misconception is that "Coupon Code" is a checkout form field, when it's really it's own separate form, so of course - it doesn't want to be nested directly inside the checkout form (you can't have forms inside forms).
This means you have real two options, without doing something crazy like rebinding a click handler on the submit button to submit the form:
Use a hook that comes after the checkout form, such as woocommerce_after_checkout_form instead of woocommerce_after_order_notes.
Keep the coupon form at its original location.

VBScript HTA Form - Click Button In IE

We're creating a HTA file so withe the information the user has input, we can automate the process of logging a ticket. The user will input the information in the HTA form and click Submit. This will then open a link in IE, input the data from the HTA to the relevant fields and then automatically click the Submit button at the end of the page.
The majority of it works so far but I'm unable to automate the Submit action. I've checked various forums but haven't been able to get this working with any suggestions so far. I'm just looking for a way to automate clicking the submit button in the IE window.
There are 3 buttons on the IE page and I'm not sure how to specify I want to click submit.
New to VBScript so any help is much appreciated.
<input value="Reset" onclick="return myReset();" class="secondary" type="button">
<input value="Add to a Bundle" onclick="return myAddRequisition();" class="secondary" name="submitorderform" type="submit">
<input value="Submit " onclick="return myOrderNow();" class="primary" name="submitorderform" type="submit">
I think the code that you posted is kind of weird, since it has two buttons with the same name.
I assume that the webpage in IE to which the information is to be sent contains only one form.
I also assume that an instance of IE automation object is stored in IE variable.
After you filled out the form via your HTA programmatically, if you want to simulate a click on the button "Add to bundle" , use the code below:
var frm = IE.document.forms[0];
for (var i = 0;i < frm.elements.length;i++)
if (frm.elements[i].type == "submit" && frm.elements[i].value == "Add to a Bundle")
frm.elements[i].click();
Or, if you want to click on the button "Submit ", you can use the code above, but be sure to replace "Add to a Bundle" with "Submit ".
Edit: In VBScript, you can use the code below:
Dim frm, i
Set frm = IE.document.forms.item(0)
For i = 0 to frm.elements.length - 1
If frm.elements.item(i).value = "Add to a Bundle" And frm.elements.item(i).type = "submit" Then
frm.elements.item(i).click
End If
Next
Edit 2: According to your comments, i guess you don't wait for your webpage until it is completely loaded. Thus, you get an Unspecified Error. To solve this problem, you should set an interval to repeatedly check if IE.ReadyState equals 4. To do so, use the code below after calling Navigate method of IE:
Dim interval
interval = window.setInterval(GetRef("fillOutForm"), 1000)
Sub fillOutForm()
If IE.ReadyState = 4 Then
window.clearInterval interval
'Here place code that fills out the form in the webpage and submits it.
End If
End Sub
As you can see, you should call setInterval method and set the first parameter to a function pointer. Use the GetRef function to obtain a function pointer. In the code that I sent, I passed a pointer to the subroutine fillOutForm. So this subroutine will be called every 1 second. In this subroutine, you check if IE.ReadyState equals 4 then you fill out the form and submit it.

Spring mvc persist data when dijit dialog is closed

I have a create view where the user and fill some data and if they click on a button a dijit.dialog opens with a list of items to select. Everything works fine, except that when the dialog confirms the selected items it goes to the controller to do some logic and refreshes the create view deleting the data that the user filled previously.
How can I make the dialog persist what the user already filled (maybe going to the controller to set the data before opening it)? Or maybe try to close the dialog, refresh the list that I show on the dialog and part of the create view that uses what the user selected.
Not sure if I make myself clear enough.
Edit
My project is based on Spring Roo:
<form:create .....>
.. inputs and tables ..
<input type="button" ../> //goes to controller and loads page with dialog open
<tiles:insertTemplate template="/WEB-INF/views/dialog.jspx" />
</form>
Dialog code:
<div id="dialog" dojoType="dijit.Dialog">
<form id="items" dojoType="dijit.form.Form">
<jsp:doBody/>
<input id="save" type="submit" name="sendDialogData">
</form>
</div>
I thought that would make the dialog part of the form but just checked with firebug and it is created after the "wrapper" (the div that contains everything)

Crystal report hangs on drill down after print

In my ASP.NET app using the crystal report viewer (ver 13.0.2000.0), when the user clicks "Print" and then either prints or cancels out of printing, when they next Drill Down in the report it will hang forever with the crystal dialog "Please wait while the document is being processed" with spinning triangle circle animation.
It does this in IE and Firefox, but it does NOT do this in Chrome: Instead the print button launches the PDF export with the "The viewer must export to PDF to print." messaging. This is what older versions of crystal did.
Right now I'm going down the road of forcing IE and Firefox to do the same thing as chrome - but if there's a real solution to the print problem - I'd rather use that. It seems when a user clicks Print (vs. export) they want to print (vs. export).
I came up with a work around for this. Since Crystal Reports does not allow overriding the buttons I ended up hiding the print button and adding my own print button using JavaScript/jQuery.
Here is some under-the-hood info on how the printing works. When you press the print button it does a postback with the view states and event arguments. The post back returns a PDF file which the browser opens inline. The PDF file is embedded with a print command which is executed when the file is opened.
So what we can do is use a hidden IFRAME to load the printable PDF. This way the main page is not affected. I think the PDF loading inline is what causes the page/browser to corrupt its state.
Place the below code at the top of your ASPX page. You must place it at the top of the page otherwise the print dialog will be off the screen if you put it at the bottom.
Here is the HTML:
<iframe id="HiddenFrame" name="HiddenFrame" style="display: none;"></iframe>
<form id="PrintForm" action="MyPage.aspx" method="post" target="HiddenFrame">
<!-- Change the name if your object is not named 'CrystalReportViewer1' -->
<input type="hidden" name="__CRYSTALSTATECrystalReportViewer1" id="CRState" />
<input type="hidden" name="__VIEWSTATE" id="VState" />
<!-- Change this value to match your CrystalReportViewer object's name. -->
<input type="hidden" name="__EVENTTARGET" value="CrystalReportViewer1" />
<!-- This is the print command that is sent. -->
<input type="hidden" name="__EVENTARGUMENT" value='{"text":"PDF", "range":"false", "tb":"crpdfprint"}' />
</form>
As mentioned above, the IFRAME will load our PDF. The form is used to do a POST to the server with the view states and event arguments. The target attribute tells the form to load in the IFRAME.
Here is the JavaScript:
// Hide the print button.
$('#CrystalReportViewer1_toptoolbar_print').hide();
// Inject our own print button. You can apply the same icon to your print button using CSS to make it look like the original icon.
$('#CrystalReportViewer1_toptoolbar_print').parent().append('<div id="PrintButtonOverride"></div>');
// When user clicks our print button, copy the states and submit the form.
$('#PrintButtonOverride').click(function () {
$('#CRState').val($('#__CRYSTALSTATECrystalReportViewer1').val());
$('#VState').val($('#__VIEWSTATE').val());
$('#PrintForm').submit();
});
The click event copies the two view states from the main page and then submits the form. I wrote this post quickly so I apologize if I left something unclear.

Is there a way to use Thickbox with dynamic content?

Here's the scenario:
I have a textbox and a button on a web page. When the button is clicked, I want a popup window to open (using Thickbox) that will show all items that match the value entered in the textbox. I am currently using the IFrame implementation of Thickbox. The problem is that the URL to show is hardcoded into the "alt' attribute of the button. What I really need is for the "alt" attribute to pass along the value in the textbox to the popup.
Here is the code so far:
<input type="textbox" id="tb" />
<input alt="Search.aspx?KeepThis=true&TB_iframe=true&height=500&width=700" class="thickbox" title="Search" type="button" value="Search" />
Ideally, I would like to put the textbox value into the Search.aspx url but I can't seem to figure out how to do that. My current alternative is to use jQuery to set the click function of the Search button to call a web service that will set some values in the ASP.NET session. The Search.aspx page will then use the session variables to do the search. However, this is a bit flaky since it seems like there will always be the possibility that the search executes before the session variables are set.
Just handle the onclick of your button to run a function that calls tb_show(), passing the value of the text box. Something like
... onclick = "doSearch()" ...
function doSearch()
{
tb_show(caption, 'Search.aspx?KeepThis=true&q=\"' +
$('input#tb').val() +
'\"&TB_iframe=true&height=500&width=700');
}
If you read the manual, under the iframe content section, it tells you that your parameters need to go before the TB_iframe parameter. Everything after this gets stripped off.
Here is an idea. I don't think it is very pretty but should work:
$('input#tb').blur(function(){
var url = $('input.thickbox').attr('alt');
var tbVal = $(this).val();
// add the textbox value into the query string here
// url = ..
$('input.thickbox').attr('alt', url);
});
Basically, you update the button alt tag every time the textbox loses focus. Instead, you could also listen to key strokes and update after every one.
As far as updateing the query string, I'll let you figure out the best way. I can see putting a placeholder in there like: &TB=TB_PLACEHOLDER. Then you can just do a string replace.
In the code-behind you could also just add the alt tag progammatically,
button1.Attributes.Add("alt", "Search.aspx?KeepThis=true&TB_iframe=true&height=500&width=700");

Resources