I want to put some hidden columns in the Webgrid. there a few key columns in my output which are not to be shown to the users but I need them to be present in the webgrid. I require these columns in the grid because when a user selects the row in the grid and clicks on modify I need those keys to get the details of selected columns.Can you please tell me how can I have a hidden column in the webgrid?(razor vb.net syntax please)
See Bianca Huluban's answer posted here: http://forums.asp.net/t/1750407.aspx/1
#{
Dim grid As New WebGrid(Model)
#grid.GetHtml( _
columns:= grid.Columns(grid.Column( _
null, _
null, _
format: #<input type="hidden" name="itemId" value="#item.Id"/>))
}
You can put hidden column inside the S.No. column
grid.Column(header: "S.No.", format: #<text> <div> #(item.WebGrid.Rows.IndexOf(item) + 1) <input type="hidden" value="#item.Id" /> </div> </text>),
enjoy this will not show the column space also
Related
I am using the Google Places API service(https://developers.google.com/places/web-service/) to get the place id based on location name. The user types some location name and related suggestions appear from which the user can select and get the place Id. I have a requirement where I need to have three textboxes and a button. The user will enter Place Name, City Name and Address and click the button to get placeId. Right now, I don't see an option to get place Id based on more than one parameter. How can I accomplish that?
Text Search Requests accept a query string. One potential solution would be to allow your users to enter the place name, city, and address into different text fields, but then concatenate all of them into a single query string before sending your ajax request.
Your form looks something like this:
<form id="form">
<input type="text" name="place" value="">
<input type="text" name="city" value="">
<input type="text" name="address" value="">
<input type="submit" value="Locate">
</form>
Your javascript will look something like this:
$( "#form" ).submit(function( event ) {
// concatenate places into a single query string
var query = $('input[name="place"]').val() + $('input[name="city"]').val() + $('input[name="address"]').val();
// convert spaces to '+' symbol for query
query = encodeURIComponent(query);
// send ajax request
$.ajax({url: "https://maps.googleapis.com/maps/api/place/textsearch/xml?query=" + query + "&key=YOUR_API_KEY", success: function(result){
alert('success, now retrieve your id from result variable');
}});
//prevent the submit button from reloading the page
event.preventDefault();
});
I have 2 forms that I am testing using TestStack.Seleno. Both forms have a checkbox that is mandatory. The first form has (including the checkbox) 5 fields. I can use TestStack.Seleno to create a passing test with valid data. I set the checkbox like this:
Input.TickCheckbox(f=>f.Accept,form.Accept);
On my other form which has 10 or so fields, when I try to set the checkbox to be ticked (using the same code) nothing happens. However when I try
var acceptCheckBox = Find.Element(By.Name("Accept"),new TimeSpan(0,0,0,50));
if (form.Accept)
{
acceptCheckBox.Click();
}
I get error "Element is not currently visible and so may not be interacted with"
Element is clearly visible and is not injected in using javascript.
I am using latest version of TestStack.Seleno from github.
Any ideas?
So I have managed to figure out what the issue is and have a work around, however I cannot explain why it works on the other form. The mandatory Accept field has html generated by mvc that looks like
<div>
<input class="check-box" data-val="true" data-val-mustbetrue="The Accept our field is required" data-val-required="The Accept our field is required." id="Accept" name="Accept" type="checkbox" value="true"><input name="Accept" type="hidden" value="false">
<label for="Accept">
Accept our Please accept our Terms and Conditions
</label>
<span class="field-validation-valid" data-valmsg-for="Accept" data-valmsg-replace="true"></span>
</div>
So you have the checkbox and hidden field both with id Accept, I suspect in code seleno is picking up the hidden field and setting value, so I updated my code todo
var acceptCheckBox = Find.Element(By.CssSelector("#Accept.check-box"));
acceptCheckBox.Click();
Now everything works.
Ismail
I have a html markup like this:
<html>
...
<body>
....
<fieldset>
<legend>Other Details</legend>
<div>
<input type='text' id='txt1' title='Detail 01'/>
</div>
<div>
<input type='text' id='txt2' title=''/>
</div>
<div>
<input type='text' id='txt3' title=''/>
</div>
<div>
<input type='text' id='txt4' title='Detail 04'/>
</div>
</fieldset>
.....
<body>
</html>
This is what I want to do.
I need to rapidly traverse the screen, pick up all the textboxes and their titles. When I encounter a textbox that has no title (like two of them in my above example), I need to check if they occur under a fieldset, which they do. Now, for these textboxes without a title, all I have to do is to take the legend value of the fieldset and assign it to the textbox.
For example, the second and third textboxes in the above example do not have a title. In this case I want to do the following:
Take the legend value of the containig fieldset (in this case, "Other Details")
Derive the position of the textbox in the fieldset and append it to the fielset legend like Other Details 2
Do the same thing for the third textbox.
I achieved step 1. When I am in step 2, I need to find out the position of the textbox in the parent fieldset. I have my selenium webdriver code below:
WebElement textbox = driver.findElement(By.id("txt2"));
List<WebElement> precedingSiblings =
textbox.findElement(By.xpath("preceding-sibling::input[#type='text' or #type='Text' or #type='TEXT']"));
String myTitle =
fieldSetLegend + " " + Integer.toString(precedingSiblings.size()+1);
I expect this code to give me the value of myTitle to be Other Details 2 and Other Details 3 for my second and third textboxes.
But the problem is, everytime I hit precedingSiblings.size(), it always returns 0. That is because each input is contained within a div and hence has no siblings.
Now, I want to know of a way through which I can find at what position my current element is within the containing fieldset.
Please help.!!!
What about navigating to the parent div finding it's preceding sibling & then finding the relevant input from there.
Roughly:
parent::div/preceding-sibling::div/input[#type='text' or #type='Text' or #type='TEXT']
How can I paste a text to the text area within a form in the browser control?
I think how i have selected is correct
browser1.Document.Forms.GetElementsByName("editform").GetElementsByName("input")
UPDATE:Here is the Html
....
<form name="editform">
<textarea name="input">
</textarea>
</form>
...
Here is an example of how it can be done based on the HTML you've provided. You must first add a reference to MSHTML via the Microsoft.mshtml. Also, I would recommed adding an id attribute to the text area then you can get to it much easier. Something along these lines.
<form name="editform">
<textarea id="myTextArea" name="input">
</textarea>
</form>
Then you can set the value property of the text area.
Dim textArea As HTMLTextAreaElement
textArea = WebBrowser1.Document.GetElementById("myTextArea").DomElement
textArea.value = "Hello World!"
Figured out it's not possible due to security reasons.
I need to build a form that loads a table that in each row contains a checkbox and an input text (the number of rows is variable, because it's loaded from a db). So my questions are:
What fields should the associate formbean have ? ArrayLists ? One HashMap ?
How can I know (once the form is submitted) what checkbox was selected so I consider the corresponding input text ?
I'm using struts 1.X as framework.
Thanks in advance!
Personally, I would use an array (list) for the checkboxes and a map for the input texts. You have to consider the fact that checkboxes are not sent on the request if they are not selected, but all your input texts are always sent. So, match the value of a checkbox with the map parameter of an input text, something like:
<input type="checkbox" name="ckName" value="val1" ../>
<input type="text" name="mapMethod(val1)" ../>
<input type="checkbox" name="ckName" value="val2" ../>
<input type="text" name="mapMethod(val2)" ../>
<input type="checkbox" name="ckName" value="val3" ../>
<input type="text" name="mapMethod(val3)" ../>
...
This means you will always have a map with all values:
val1 = "textbox 1 value"
val2 = "textbox 2 value"
val3 = "textbox 3 value"
...
and also have a list of selected checkboxes which can be:
[val1]
[val1, val2]
[val1, val2, val3]
... different combinations or []
You then keep the textbox values from the map only for the keys that are found in your list of checkbox values.
P.S. Remember also to reset your checkboxes.