I have an asp.net page with 4 tab controls using the following html for each (changing their ID's for each one etc):
<ul id="ulTabs">
<li class="displayItem" id="liSummary" style="display: block"><a ref="#divSummary">
<span style="font-weight: bold; color: #4b6c9e">Margin Analysis Summary</span>
</a></li></ul>
The problem I have is that, on two of the tabs I have GridViews that open a new modal/screen. When this modal/screen is then closed, the page refreshes and the focus automatically goes back to the first tab regardless of which tab was selected when the modal/screen was opened.
Any ideas on how I can keep focus set to the current tab? I've tried a few solutions on different links but have found nothing so far.
Store the ID of the currently opened tab in a HiddenField when the tab opened is changed.
Then on load (after the refresh) open the tab represented by the ID stored in the hidden field.
I've done this with javascript and jquery when I've used jquery tabs in the past and it works really well. In fact, if it helps, here's how to do it with jquery. I'm sure you'll be able to adapt it for your own needs (or if you're doing it all in the code behind the page then it'll be even easier).
Related
Background
Here's what I want to happen:
A user is on one page1.html (jsFiddle).
When they click on one of the <a href...> links, I want to navigate to page2.html (jsFiddle) and simulate the user entering the number into the textbox and clicking on the button.
Example: On page1.html, user clicks on display 2. Then we will navigate to page2.html and get an alert of 2 (as if user had entered 2 and clicked the button).
Question
How do I do this?
Is there a way to make a C# method with a specific URL to navigate to, such as page2.html/searchfor/2?
Or is there some way in JavaScript to manually go about doing other things after navigating to <a href="page2.html">?
Things I've tried
Using a <span> with an onclick function, but then it's not a true link like <a href> where I can middle click to open in new tab and right click to follow link
Wrapping my first attempt in <a href> tags, like <span>Display 2</span>. This still doesn't solve the problem of performing extra actions after navigation.
Note
I am building this webpage using Entity Framework, ASP.NET MVC, and C#.
I have simplified the problem for discussion purposes, but the concept is the same.
Try using the page2.html document's onload() function. You can pass parameters through the URL, then take that data and perform "other actions" as soon as the document is loaded.
I'm currently trying to spider a page that seems to have a dynamic form. First let me explain the form. The form has 3 radio dials above the search bar that has the first dial selected upon loading. I need the second dial selected. After selecting the second dial from the 3 dials I need to fill out the search bar which is actually a drop down,
in the inspector looks like
" id="*****" class="ui-autocomplete-input" type="text" size="60" name="*****" style="font-size:20px;width:90%;;" autocomplete="off" role="textbox" aria-autocomplete="list" aria-haspopup="true">>"
Originally the html behind the search/submit button looks like
a id="submit_button" style="display:none;" href="#">
After selecting from the dropdown menu the html behind the search/submit button looks something like
a id="submit_button" style="" href="report.php?**=Mzg4MDU4NQ%3D%3D&**=MjQ1NDM2NQ%3D%3D">
Obviously the stars are there to keep the page anonymous. I'm using a Web client to spider this page.
All I need to grab from this page is the new href link which is dynamically changed after a item is selected from the drop down. I need to simulate this in C# and parse the href link. Frankly, I don't know where to even begin.
I have tried using a nameValueCollection to fill in this form using UploadValuesAsync() but no avail.
I am new to the ASP.NET world and I need to do a popup to select some data.
The idea is that the user can select one or more options with a CheckBox. When he presses a button a popup appears with a list of options loaded from the database.
I don't know how to create a popup with those options and receive the selected options when the popup close. But I know how to do the option list from the database with a repeater.
there is no such popup control in ASP.NET.
However there are numerous 3rd party plugins, which provide popup controls.
ajax tool kit model popup extender
jquery built popups
you can create your own. popup is nothing but a hidden container, which appears upon some action, and whose location and background is as per your choice.
create a popup like this:
<div class="parent">
<div class="popup">
</div>
</div>
<input type="button" value="popup" id="btnpopup" />
and css
.parent
{
position:relative;
background-color:#CCCCCC;
width:200px;
height:200px;
}
.popup
{
width:50%;
height:50%;
position:relative;
top:20%;
left:20%;
background-color:#DDDDDD;
display:none;
}
and jQuery code
$('#btnpopup').click(function(){
$('.popup').toggle(200);
});
see this fiddle
You can use the OnClientClick of the button to open the popup. Depending on it being a normal browser popup or a jQuery dialog you have two general options:
Standard Popup
Standard popups open as if they are a separate page. When you click OK you may have to store the selection into the user's session if the data is needed on the page that triggered the popup, or store it directly in the database. If the former is the case, when you return to the page and submit it, the data from the popup will be available in the session to process.
jQuery Dialog or particularly any js-triggered html dialog. You can show it with the corresponding js again in the OnClientClick function, and perform the selection. On the OK button click of the dialog almost nothing is needed (except hiding it). Since the dialog input controls are part of the page, they will be posted on submit and be process-able on the server.
That's basically all you need to do, but some more reading on the topic won't hurt. Good luck.
What I’m trying to accomplish is this. I want it to be so that when the user clicks a button, a pop up comes up and allows them to complete, say, the survey. However, I do NOT want it to be a popup window, just something like in the image. Additionally, the pop up needs to be able to have a webpage embedded in it, because the survey is a page in itself. So basically, instead of it being that when the user clicks the button they are redirected, I want a pop up (not a popup window) to appear with the page in it. What I have used so far is iframe in a panel, but I feel there must be a better and more stable way, than using frames. Can anyone suggest a better method? Sorry about my terminology, if have no idea what this is called, I’m new to .ASP NET wed development.
Here is the code (the button changes visible=”False” to true):
<asp:Panel CssClass="BlowItUp" ID="Panel1" runat="server"
Visible="False" >
<iframe src="http://10.0.0.1/start.htm" style="width:100%; height:100%; top:0px;" />
</asp:Panel>
The CSS if it matters:
.BlowItUp
{
position:absolute;
width:80%;
height:90%;
z-index:300;
right:10%;
top:5%;
padding:0px;
}
Unless you have control over the "inner" page, I think a frame is the best you're going to manage. Otherwise the inner page will seek to navigate to another page and you'll lose your "framing".
The one thing I would suggest though is a different popup panel. Say jQuery UI Dialog?
I have a pretty simple web-form set up in .Net where I am leveraging jQuery for some of the functionality. I am using the DOMWindow portion for part of the presentation layer.
There is a login form in a div that is set to display:none. When a user clicks a button on the page, it displays the login form. However the .Net button for the login form will not fire it's event when display is set to none. If i take this out, it fires fine. I have also tried using the visibility attribute, but no luck.
the div code is:
<div id="Login" style="display:none;">
The launching code is:
click here to login.<br />
the jQuery code is:
function LaunchLoginWindow() {
$(document).append("#Login");
$.openDOMWindow({
loader: 1,
loaderImagePath: 'animationProcessing.gif',
loaderHeight: 7,
loaderWidth: 8,
windowSourceID: '#Login'
});
}
Any help or explanation that anyone can offer is appreciated.
I noticed i had some code in there defining a client-side function on the Login div. I removed this so as to eliminate it as a possible issue.
I can see in your code that you are appending the div #Login but not setting its style property back to normal like block so. Set it back to block and i am sure it will work
try adding somthing like:
$(document).append("#Login").show();
OK, after playing around with this using firebug, I found the issue: When the jQuery plug-in DOMWindow creates its display layer, it appends to the HTML node of the DOM, which places the control outside the asp.net form tag. Therefore the button and actions associated with it via the DOMWindow are not recognized by .Net. So i edited the DOMWindow source file to append to the DOM form node rather then the html node.
The drawback is that the source has now been customized and will have to be QA'd thoroughly, especially if any further changes are made. But I hope to manage this effectively via commenting in the file.
Hope this helps anyone else who hits this issue.
pbr