ASP.NET MVC3 Postback brings up new TAB - asp.net

net MVC View. At the end of the view I have the following Buttons
<div style="clear: both; padding-top: 40px; width: 720px;">
<button name="buttonHelp" value="Help" onclick="window.open('Help.htm',target='_blank');return false;">
Help</button>
<span style="float: right;">
<button name="button" value="Reset">
Reset</button>
<button name="button" value="Save">
Save</button>
</span>
</div>
The Save and Reset causes a postback and the screen gets refreshed properly.
If I click the help button it opens the Help screen in s new TAB which is what I require.
Now after using the help screen I press Save/Reset it always open a new window which I dont want and I find puzzling.
Any idea how to solve this ?

The following change solved the problem. the help still opens in a new tab as I wanted
> <button name="buttonHelp" value="Help"
> onclick="window.open('Help.htm');return false;">
> Help</button>

Check to ensure that the target isn't staying "_blank" after you click Help and that the target of the form is _self.

Related

Add class to ian:accounts-ui-bootstrap-3 SELECT tag when rendered [Meteor JS + Blaze]

Meteor 1.6.1.1 is the latest version of my project. I am using package ian:accounts-ui-bootstrap-3 instead of accounts-ui. I have added a custom field as <select> in the code.
What I get on Screen is as below.
When I saw the HTML code, it is not adding class="form-control" to select tag.
below is the code when I inspect element on UI using Chrome.
<li id="login-dropdown-list" class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" aria-expanded="false">Sign in / Join <b class="caret"></b></a>
<div class="dropdown-menu">
<div class="select-dropdown">
<label>State</label><br>
<select id="login-state">
</select>
</div>
<button class="btn btn-primary col-xs-12 col-sm-12" id="login-buttons-password" type="button">
Create
</button>
<button id="back-to-login-link" class="btn btn-default col-xs-12 col-sm-12">Cancel</button>
</div>
</li>
All I want is to add class="form-control" to the select tag dynamically when component loads on screen and it must look like below;
I have tried below code, but it is not working;
Template.HomePage.onRendered(function () {
document.getElementById('login-state').classList.add('form-control');
});
Well, I tried one way to achieve this is by using Template event as below,
Template.HomePage.events({
'click #login-dropdown-list': function(event){
//document.getElementById('login-state').classList.add('form-control');
$('#login-state').addClass('form-control');
}
});
As you can see, the component gets loaded inside the li tag with id="login-dropdown-list". I simply loaded the class on click event. Even the commented code works fine.
Is this a good solution? please let me know if there much better answer to this? If it works I will definitely accept and upvote the answer.

Bootstrap Modal with button type="submit"

<button type='submit'
value='".$complainListArray['CompID']."'
class='btn btn-default'
style='width:95px;float:right'
data-toggle='modal'
data-target='#myModal'
name='button_update_sentiment'
id='button_update_sentiment'
>Update</button>
I got this problem, when type='submit', then the Bootstrap Modal is not showing.
It works when I use type='button', but then I can't carry the value of the button.
Need help. Thanks

How to traverse and click on Next & Cancel Button (On PopUp) using selenium webdriver

I have a pop up window on webpage where in I need to click on "Next" and "Cancel" button. I have tried navigating and find the CSS selector but couldn't able to locate and click on Next & Cancel button.
Below is the Fire bug things when I got after hovering on Next & Cancel Button.
<div class="ui-dialog-buttonpane ui-widget-content ui-helper-clearfix">
<div class="ui-dialog-buttonset">
<button class="ui-button ui-widget ui-state-default ui-corner-all
ui-button-text-only" type="button" role="button" aria-
disabled="false">
<span class="ui-button-text">Next</span>
</button>
<button class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" type="button" role="button" aria-disabled="false">
<span class="ui-button-text">Cancel</span>
</button>
</div>
</div>
You can search by xpath and the button text
// click on next button
driver.findElement(By.xpath("//span[contains(text(), 'Next')]")).click();
// click on cancel button
driver.findElement(By.xpath("//span[contains(text(), 'Cancel')]")).click();
Or using cssSelector
driver.findElement(By.cssSelector(".ui-button-text:contains('Next')")).click();
driver.findElement(By.cssSelector(".ui-button-text:contains('Cancel')")).click();
Basically if it is a popup, there are three types: alert, confirm and prompt. I will give you the solution for the alert which should work with confirm as well and try it. Please let me know if it works and I can help you if I have more info. I am using C#. Use the "SwitchTo() method of IWebDriver interface and Alert() method of the IAlert interface (this has got Accept and Dismiss methods which are your OK/Cancel on the popup).
Code: (assuming the action that fires the popup has been performed)
IAlert alert = Driver.SwitchTo().Alert();
alert.Accept();
//or alert.Dismiss();
In case clicking on the span (as per #Guy's answer) doesn't work, try -
// click on next button
driver.findElement(By.xpath("//button[contains(., 'Next')]")).click();
// click on cancel button
driver.findElement(By.xpath("//button[contains(., 'Cancel')]")).click();

css search form not working

so I upgraded my site into responsive template, all done but stuck here!
so I know this is something very simple as a b c , but for the life of me cannot fig it out :*(
http://www.example.com/cards/holiday-greeting-cards.php
here on top right the search button with magnifying glass icon... how to make it work!
the other search button which says "search holiday cards"(which will be removed once this one starts working) is working fine...
can anyone please please help please
thanks in adv
This isn't perfect solution and it's a more of a hack, but it's really short and does its job.
Append this just after: <input type="text" placeholder="Search">
<input type="submit" style="
width: 30px;
margin-left: -40px;
opacity: 0;
">
If you add a class to your input box (you can also do an input find in search_box)
<div class="search_box pull-right">
<input type="text" class="search_input" placeholder="Search">
</div>
You can use jQuery to get the content (this example only reacts to the enter key)
$('.search_input')
.keypress(function(e) {
if(e.which == 13) { // if you press enter
window.location.assign('/cards/search-results-xmas.php?keywords=' + $('.search_input').val());
}
});

Bind GridView via jQuery ajax

I am new to jQuery, trying to populate a GridView or Telerik RadGrid using jQuery. Not sure how to go about it and unable to find any examples. Any help is appreciated. Thanks.
Essentially I am trying to display a modal window with a textbox and button. The user enters a search criteria presses the button and a gridview in the same modal window is populated with the results.
The user than selects records in the grid presses another button and the selected users are inserted into the database table, modal window is closed and a grid on the parent page is refreshed showing the new added users.
<input type="button" id="btnAddNewUserj" value="Add New User" />
$(document).ready(function() {
$("#btnAddNewUserj")
.click(function() { ShowNewUserDialog(); return false });
$("#btnSearch")
.click(function() { FindUsers(); return false });
});
function ShowNewUserDialog() {
$("#newuserDialog").dialog({ modal: true, bgiframe: true }).dialog("open");
}
function FindUsers() {
// HOW TO DO THIS?
// Show selectable list of users from the database in grid.
}
<div id="newuserDialog" title="Add New User" style="display:none;">
<div>
<input id="txtSearchFor" type="text" />
<input id="btnSearch" type="button" value="Search" class="Button" /></div>
<p> DISPLAY RESULTS HERE </p>
<div style="margin:10px 6px;">
<input type="button" id="btnjAdd" value="Add" class="Button" />
<input type="button" id="btnjCancel" value="Cancel" class="Button" />
</div>
</div>
A couple of thoughts here. You cannot populate a GridView or Telerik Grid using jQuery. jQuery is a client side technology and those two grids are server side.
You can use jQuery to hit a web service and build out and HTML table with the results (which is basically what a GridView does).
I'm guessing however, that you would be better served just using native GridView databinding. You can use a .Net UpdatePanel around the grid if you want to prevent full post backs.
I think telerik is not the answer.
Use telerik radgrid's client side binding, see this for an example: http://demos.telerik.com/aspnet-ajax/grid/examples/clientbinding/defaultcs.aspx
Note that sample shows how to bind to a WCF Web Service and an ADO.NET Data Service. There are other samples around.
Other variations of binding: http://demos.telerik.com/aspnet-ajax/grid/examples/client/declarativedatabinding/defaultcs.aspx
More on client side binding: http://demos.telerik.com/aspnet-ajax/grid/examples/client/databinding/defaultcs.aspx

Resources