I have am using JQuery Mobile in asp.net web form and on button click I want to load the list. In code behind I am getting the list is this way
List<Reportee> associates = new List<Reportee>();
associates = DALLayer.GetReporteeForEmployee(EmployeeId);
Here, associate is a class which has two property [reporteeName and reporteeId].
How can I show all the reportee Name in the list?
print a <ul> tag
for each associate:
print <li>
print the text you want
print </li>
when foreach ends print </ul>
I have no idea why you asked...
What does it have to do with jquery mobile? O, I know! Instead of <ul> print <ul data-role="listview">
Related
I have a view called LoggedIn.cshtml getting called from LoggedInController.
Inside the LoggedInView I have a PartialView called _LoggedInPartial to display the nav bar containing different menus like Home, Profile, etc.
I want to call another view LoggedInHomeView onClick of the home menu of the nav bar which is present inside LoggedInView.
How can I achieve that?
Say you have view called LoggedIn.cshtml, in your view you render partial view called _LoggedInPartial like:
{ Html.RenderPartial("_LoggedInPartial"); }
Generally, if _LoggedInPartial is used for navigation inside this view, links are rendered like:
<ul>
<li>
#Html.ActionLink("Title", "ActionName", "ControllerName")
</li>
<li>
#Html.ActionLink("AnotherTitle", "AnotherActionName", "AnotherControllerName")
</li>
</ul>
Now, when you click on links you should be redirected to desired action, and it will render view for you.
Use
#{Html.RenderPartial("View", "Controller");}
I am writing a selenium script that automates a web-page. I need to click on a button which is defined within a list.
This is the image of my web UI - New Account is the button I am referring to
This is my XML code :
<div id="00B4E000000LQ2C_topNav" class="topNav primaryPalette">
<div id="00B4E000000LQ2C_subNav" class="subNav">
<div class="linkBar brandSecondaryBrd">
<div id="00B4E000000LQ2C_listButtons" class="listButtons">
<ul class="piped">
<li>
<input class="btn" type="button" title="New Account" onclick="navigateToUrl('/setup/ui/recordtypeselect.jsp?ent=Account&ekp=001&retURL=%2F001%3Ffcf%3D00B4E000000LQ2C%26isdtp%3Dnv%26nonce%3Df8007ad94993912b7ff4149193a6096ccfed4ebb1454e0b9b310ad14b61de71d%26sfdcIFrameOrigin%3Dhttps%253A%252F%252Fcs83.salesforce.com&save_new_url=%2F001%2Fe%3FretURL%3D%252F001%253Ffcf%253D00B4E000000LQ2C%2526isdtp%253Dnv%2526nonce%253Df8007ad94993912b7ff4149193a6096ccfed4ebb1454e0b9b310ad14b61de71d%2526sfdcIFrameOrigin%253Dhttps%25253A%25252F%25252Fcs83.salesforce.com&isdtp=vw','LIST_VIEW','new');" name="new" value="New Account"/>
</li>
<li class="lastItem">
</ul>
I used:
driver.findElement(By.xpath(".//*[#id='00B4E000000LQ2C_listButtons']/ul/li[1]/input")).click();
(Xpath was given by the firebug) but it gives me an error stating
unable to locate elements
Please help me script / locate this button.
You don't have to use XPaths generated by the Firebug and check the element's parents along the way. We can do better, you can write a more reliable and a simpler way to locate the element:
driver.findElement(By.name("new"));
or:
driver.findElement(By.cssSelector("input[name=new]"));
or:
driver.findElement(By.cssSelector("input[value='New Account']"));
Note that the XPath expression you have looks valid. You may be experiencing a timing issue and would need to wait for the element presence, visibility or clickability, see: How to wait until an element is present in Selenium?.
And, if the button is inside the iframe, you need to switch to its context and only then search the button:
driver.switchTo().frame("ext-comp-1005");
Hi please try like below
// first way
driver.findElement(By.xpath("//*[#name='new']")).click();
// second way
driver.findElement(By.xpath("//*[#class='btn']")).click();
// basically you can use various attributes of input tag with button inside the xpath to click
Update working with i frame
// A short way to identify how many iframe's are present on a web page
List<WebElement> numberOfFrames= driver.findElements(By.tagName("iframe"));
System.out.println("Total Number of iframes present are : " +numberOfFrames.size());
for(int i=0;i<numberOfFrames.size();i++){
// here u can identify iframes with any of its attribute vale say name,title or which is most suitable.
System.out.println("Name of the i-frames : " + numberOfFrames.get(i).getAttribute("name"));
}
// Back to your question - button lies inside iframe hence
// key here is before clicking you have to switch to the frame first
driver.switchTo().frame(driver.findElement(By.name("frame name")));
hope this helps you
<ul id="audio-player-playlist">
<li class="playlist_item" data-song_title="title" data-song_artwork="" data-song_file="http://example.com/mysong.mp3" data-song_artist="Artist"></li>
<li class="playlist_item" data-song_title="title" data-song_artwork="" data-song_file="http://example.com/mysong.mp3" data-song_artist="Artist"></li>
<li class="playlist_item current" data-song_title="title" data-song_artwork="" data-song_file="http://example.com/mysong.mp3" data-song_artist="Artist"></li>
</ul>
This is the list generated by my audio player. When I click play, the playlist_item_current class is added to the song that's playing.
The thing is I want the users the be able to share the song playing. How can I get the current song's data and put it in my share button?
I suspect that the music player you are using is created in javascript & you probably are already using jQuery as well so in that case:
in jQuery you can easily do the following to retreive the songname from the currently playing song:
$('.playlist_item.current').data('song_title');
For the artist:
$('.playlist_item.current').data('song_artist');
These functions would return the necessary data.
I have a menu bar on layout page and put it in a section on layout.
#section MenuSection{
<ul class="menubar">
<li>Test</li>
<li>Test</li>
<li>Test</li>
</ul>
}
I have multiple view in application associated with layout page. On some views It won't be requiring this menu bar. So I tried hiding section for that view
Index View-
#{
#RenderSection("MenuSection",required:false)
}
But this menu section disappears from layout.
What is the proper way of doing this? Is section is precise way? What would be a definition of section in layout page?
#if (SomeCondition){
#RenderSection("MenuSection", required: false)
}
The required just means that child pages don't have to specify that #section. But if you want it to display during specific circumstances, place it in an if statement.
I just looked and we get the controller and action like this
var action = (ViewContext.RouteData.Values["action"] ?? "").ToString().ToLower();
var controller = (ViewContext.RouteData.Values["controller"] ?? "").ToString().ToLower();
the put the render in an if based on this like Brad's answer
I'm using the Asp.Net CMS Umbraco and would like some help to determine whether or not there is something specific about the Umbraco CMS that might make the task of creating a multi-colored menu bar... different from standard html and css manipulation.
The menu bar code that I'm using is based upon the friendly-ghost theme shipped with Umbraco.
Now the normal method for employing different colours in a menu would be something like
div # menu ul.rMenu li.page-item-(some number) {background-color: # (whatever);}
...
...
<li class "rMenu-expand page-item-(the same number as above)"><a href="(link to whatever site on the menu)">
<span> Wording for the particular tab </span></a></li>
And bingo... the (some-number) tab has the (whatever) colour!
However, Umbraco seems to be using a different set-up that is not entirely compatible with the above strategy. Should I be looking at *umbTextpage id *parentID *nodeType ... or something entirely different that I haven't, as yet, noticed?
I believe that nodeName is being used for the wording of particular tabs... should I take it, then, that nodeType refers to the tabs themselves ???
That's great, thanks. However, the menu is generated dynamically using xslt. Do you think I should I attempt to insert that code (converted to xslt) into the menu generation process...
<xsl:for-each select="$currentPage/ancestor-or-self::* [#level=$level]/* [#isDoc and string(umbracoNaviHide) != '1']">
<li>
<xsl:if test="#id = $currentPage/#id">
<xsl:attribute name="class">current</xsl:attribute>
</xsl:if>
<a class="navigation" href="{umbraco.library:NiceUrl(#id)}">
<span><xsl:value-of select="#nodeName"/></span>
</a>
</li>
... or attempt to use razor code after the fact (i.e. have the menu be created and subsequently cycle through the menu's elements, giving a numerical 'tag' to each node)?
The beauty of Umbraco is that you have complete control of the layout. You can have it build your menu how ever you want.
I don't know whether you are using xslt or razor to generate your menu, but If you're looking trying to get a unique number to append to "page-number-" then use the node's Id, that won't change even if the name of the node is edited.
Using Umbraco 4.7 razor you do something like this:
#{
<ul>
#foreach (var node in Model.AncestorOrSelf().Children.Where("Visible"))
{
<li class="rMenu-expand page-item-#node.Id">
<a href="#node.Url">
<span>#node.Name</span>
</a>
</li>
}
</ul>
}