I need an idea for a situation like this:
There is this aspx form which contains some buttons like "save", "import", and print;
on the last one clicked a window should appear providing the user with a print-friendly version. what i need is the form not to cause postback and reload in this case, while normally postback-ing when the other buttons are clicked.
Or use hyperlink with target="_blank" to open up the document in a new window.
If you like to use the button, you have to use the window.open syntax to open a new page: http://www.javascript-coder.com/window-popup/javascript-window-open.phtml
HTH.
Related
i want to create a popup window when clicking on a button in webform and after that i want to show a user control in that popup.how to do in asp.net?
i tried with some jquery methods but nothing happens when clicking button?
i want to create a popup window when clicking on a button in webform and after that i want to show a user control in that popup.how to do in asp.net?
i tried with some jquery methods but nothing happens when clicking button?
Think about using an IFrame to achieve this, from the sounds of what you are talking an IFrame would suffice and provided the needed functionality.
<iframe src="YOUR PAGE HERE"></iframe>
There's a lot more you can do with it, these are just the tags to get you going.
Here is the problem: I have a HTML page called test.html and an ASPX page called getitem.aspx.
Now what I want to do is, upon clicking a button on test.html, I want the getitem.aspx page to open in a new dialog and allow entry on a text box. After clicking the OK button on getitem.aspx, this dialog should close and the entry should be passed back to the html page.
The issue is that the getitem.aspx has several buttons that trigger postback - but I only want the item from the text box to be sent back to test.html upon clicking of the OK button and not any other buttons.
How could I implement this?
You should use javascript to do that
first you need to use window.open() method to open the popup
after you have closed the page you should use window.opener for accessing to the closed windows and use javascript method like (getElementById) to find the element on that window and read it's value and then use !!
Hope it helps
i have created Array of Linkbutton
and when user click on link button it will create an array of Radio Buttons
but it requires Postback all time so page load takes more time...
what is solution of it??
Use asp.net Ajax update panel.
Put link buttons and panel/view (or what ever control you are using ) update panel.
I am not sure if I am following a 100% but if you don't want to do a post back then your going to need to write some javascript(or use a framework like jquery) to generate radio buttons when the user clicks the link button(plus you probably don't want to use a link button then as it will try to always cause a postback or you will need to stop the post back from happening).
LinkButtons are giving me headaches. I thought, foolishly, that they allowed you to create programmatic links. Obviously this is not the case (by design), as they have behave nothing like normal links - you can't see your address when you hover over them, you can't open them in a new tab, etc.
Is there an alternative in .NET that actually lets you programmatically create a true HTML link? The ability to open multiple items in tabs is sort of a requirement. I've looked into styling a Button to look like a link, but it still behaves like a button, so this won't work either. Any ideas?
EDIT: Sorry, forgot: can't use HyperLink, as I need the ability to send CommandArguments, set OnClick events, etc. It needs to function as a button still.
The HyperLink control.
Set the href using the NavigateUrl property, and tagets (for new windows/tabs) can be set using the Target property
Edit to respond to question edit
I'm not really sure what you're after - your question is asking for a control that "functions like a normal link", so that clicking on it can open in a new window/tab, but your edit says you want to be submitting CommandArguments and using the OnClick event - so not a normal link.
The problem you've got here is that the PostBack processing of command arguments and OnClick events happens at the server, but the "open in a new window" happens on the client (using the "target" attribute of the anchor tag, or possibly with JavaScript) - these two don't really mix all that well.
A couple of options spring to mind:
Use a LinkButton, and if you handle a PostBack, output some JavaScript to open the new page in a new window.
Use a HyperLink control with a target and set the "CommandArguments" as a querystring element to the link - you can then process that on the catching page that opens in the new tab.
You can also cause JavaScript to fire onClick using the Attributes collection:
// Create a hyperlink
HyperLink link = new HyperLink();
link.NavigateUrl = "/somepage.aspx?arg=First";
link.Target = "_blank"; // Open in a new window
// Add a client side onClick event calling someMethod function with a reference
// to the link, and making sure the link processing stops.
link.Attributes.Add("onClick", "someMethod(this);return false");
You mean HyperLink?
Of course you could always use the a tag in HTML.
EDIT: When you hover over a link, the browser displays the target. When you hover over a LinkButton, the browser displays the javascript call that will execute the function server side. I'd say the best you can do is display the target page in the ToolTip, since I think it would be pretty tough to display it in the browser.
If you use a LinkButton you will be able to set the command arguments and the onclick method in your code behind. By doing so, you will no longer be able to open the link in a new window as you have found out.
One of the reasons that you cannot open a LinkButton in a new window is because it is doing a postback to the same page.
I think you either have to use a HyperLink control and pass the command argument as a query string parameter or use a LinkButton control and loose the open in a new tab functionality.
If you pass the argument as a query string parameter, then you can check for that param in page load and still call your onclick function which you were going to use for your LinkButton.
Hope this is clear and it helps you.
I have a master page with a search box and button at the top. This search functionality is taking over the "enter" key for all my web forms that use this master page. That is, if I have a login page that uses this master page and the user enters in their username/password and hits "enter", instead of logging in the user the system performs a search.
What's the best way to set up the default submit buttons. I could wrap everything in asp Panels and set the DefaultButton property, but that seems a bit tedious. Is there a better way?
use defaultbutton property of form or panel
<form defaultbutton=“button1” runat=“server”>
<asp:button id=“button1” text=“Same Page” runat=“server”/>
<asp:panel defaultbutton=“button2” runat=“server”>
<asp:textbox id=“foo” runat=“server”/>
<asp:button id=“button2” runat=“server”/>
</asp:panel>
</form>
As you have discovered default buttons can cause issues when there is more than one button on a page. I would take the Geeks suggestion but simplify it by removing the setfocus client script and extend it by adding the keydown event to both the search textbox and the login textboxes such that the enter key fires the correct button depending on if your user is using the search box or the log in box, or any other textbox you want to add the javascript to.
You can set focus on loading the page (in code behind if you like) to save the user some mouse work or tabbing if there is a sensible control for the user to start at, but otherwise the control the user is interacting with should determine the flow of the page and what the enter key does.
set focus on the text box ,
Page.RegisterStartupScript("SetFocus", "< script >document.getElementById('" + TextBox1.ClientID + "').focus();< /script >");
and then
In the keydown event for the last textbox you can do something like this:
If e.KeyCode = Keys.Enter Then
Me.Button1.Select()
End If
Rather than using javascript to manipulate the page you could put the search box and the submit button into an IFRAME on the master page. If the focus is in the iframe clicking will submit the search form, if the user is on your main form within the page they will submit the normal page.
The <iframe> src attribute points to a little self contained aspx page holding your text box and submit button which redirects to your search results form.
This is what we tried on our project which seemed to work. I changed the Search asp:Button to be an asp:LinkButton. I then added some CSS style to give it a background image to make it look like a button. LinkButtons are apparently not used by the page for determining which Button is the default action when pressing Enter. The sweet part was that LinkButton can still have click actions associated with them so I didn't have to change any of my code-behind stuff.