I have a RadGrid with an asp Link Button. I want to highlight the row whose link button has been clicked.
Following is the code from my grid:
<rad:GridTemplateColumn
<ItemTemplate>
<asp:LinkButton ID="lnkEditRole" runat="server" Text="View Teams" CommandArgument='<%# Bind("Roleid") %>' OnClick="Editrole_Click">
</asp:LinkButton>
</ItemTemplate>
</rad:GridTemplateColumn>
Can anyone help me with this ?
Regards,
Rmn
see the html generated by the grid, then you can make a css class .highlighted and a jQuery event like this:
$("#id_of_button").click(function(){
$("#id_of_row").addClass("highlighted");
});
Simple solution. (if you can show the generated html, I can give more specific help)
Edit:
If View Leaders is you link button:
$("[id$=LinkViewTeam]").click(function(){
$(this).parent.parent.addClass("highlighted");
});
Related
I am using a linkbutton within a gridview control.I want to open the data into a new tab.I tried to set target="_blank".
But it is not working.
I have tried doing this.This is my source code:
<asp:LinkButton ID="LinkButton1" runat="server"
CommandArgument="<%# Container.DataItemIndex %>" CommandName="###"
Font-Underline="False" Text='<%# Eval("###") target="_blank" %>' />
Please guide me and give me suggestions where I am doing wrong.
Page_Load use:
btnSubmit.Attributes.Add("href", "https://google.com/");
btnSubmit.Attributes.Add("target", "_blank");
Or use javascript:
<asp:LinkButton id="lnkTitle" runat="server" OnClientClick="return NewWindow();" OnClick="lnkTitle_Click" > Open Window</asp:LinkButton>
<script type="text/javascript">
function NewWindow() {
document.forms[0].target = '_blank';
}
</script>
Good successs =))
At most you can make it open into a new window and depending on the users internet settings it will open in a new tab. There's no way to make it open in a new tab though.
http://www.webmaster-talk.com/html-forum/32504-hyperlink-target-open-in-new-tab.html
Also check out this page:
how to open a page in new tab on button click in asp.net?
<asp:HyperLink ID="jiraLink" runat="server" Target="_blank">Click Here</asp:HyperLink>
Target="_blank" does the trick for me. Either try:
Capital "T" for target
Or, in the code behind, try:
jiraLink.Target = "_blank";
Also, it looks like you may have left the ending tick mark off (or misplaced) your Text field.
If you use
OnClientClick="window.open('/folder/Report.aspx');
in your LinkButton it opens in a new tab, but it does so on left click. Right click and selecting open in new tab will also open in new tab.
With with Linkbutton the user cannot control the target.
In Web application, i am using datalist control to bind the Embed videos to a <div> dynamically. They are coming good, but when we click on video in the datalist they are start to play. I dont want that, I would like to play the particular video in a popup, and make a non action on that video [div which contain embeded video]. I want to make that div enable false.
<asp:DataList ID="DtlstVideos" ToolTip="Click On Video Title" CellPadding="5" CellSpacing="5" runat="server" RepeatColumns="5" RepeatDirection="Horizontal" OnItemCommandXSSCleaned="DtlstVideos_ItemCommand">
<ItemStyle />
<ItemTemplate>
<div id="divVideos" runat="server"><%# Eval("photos") %></div>
<asp:LinkButton ID="lnkVide" CommandName="Click" runat="server" Text='<%# Eval("videotitle") %>' ToolTip="Play" CommandArgument='<%# Eval("id") %>' Font-Bold="true" ForeColor="Blue"></asp:LinkButton>
</ItemTemplate>
</asp:DataList>
This is the current code, when a user clicks on the LinkButton a popup will fire and the video will play, but when click on div the video is playing in datalist only, is there any solution?
Id am not sure if I did understand you correct but I hope this might help.
If you are using youtub, you'll be able to access a preview picture of the movi in different-sizes.
The image is accessble via a certain convention like this:
http://img.youtube.com/vi/VIDEO_ID/#.jpg
Find details here: http://www.reelseo.com/youtube-thumbnail-image/
So what I would do is display only the image in the datalist (maybe with some div overlay which looks like a player)... and then on click pass the movi ID to your popup and then embed and play the movie in that popup...div or new window whatever you want..
HTH
Well, I would not use that <div> as you are using rather I would make use of the ImageButton that will act as the video image as when clicking you can fire your command and hooking up a javascript event on it you can fire up the popup when you want.
Let's imagine that you can use jQuery with this:
<asp:DataList ID="DtlstVideos" ToolTip="Click On Video Title" CellPadding="5" CellSpacing="5" runat="server" RepeatColumns="5" RepeatDirection="Horizontal" OnItemCommandXSSCleaned="DtlstVideos_ItemCommand">
<ItemTemplate>
<asp:ImageButton id="divVideos" CssClass="img-video" runat="server" CommandArgument="<%# Eval("id") %>" data-video-id="<%# Eval("id") %>" CommandName="Click" ImageUrl="<%# Eval("photos") %>" />
<%# Eval("videotitle") %>
</ItemTemplate>
</asp:DataList>
and with jQuery you can simply hook up the click event to fire up your pop up and your command
$(function() {
$(".img-video").on("click", function() {
var url = 'playVideo.aspx?id=' + $(this).attr("data-video-id");
window.open(url, "Video Player","menubar=0,resizable=0,width=650,height=450");
return true; // let the image button fire the command argument
});
});
But I would never let it fire the Command event here and I would hook up always in the playVideo.aspx page as there you do have the video id as well and you can do what you need in that page without needing to fire the command event on the video strip.
I am using a ASP .NET ListView with a MS SQL Database. I use the ListView to show the information and in the list view, there is an hyperlink which opens the editing window for the specific record in a jQuery Modal Dialog Box.
<asp:ListView ID="ListView1" runat="server" DataSourceID="SqlDataSource1">
<LayoutTemplate>
<div id="itemPlaceholder" runat="server"> </div>
</LayoutTemplate>
<ItemTemplate>
<!--More Items -->
<a name="Link" href="EditItem.aspx?id=<%# Eval("articleid")%>">Edit</a>
<!--More Items -->
</ItemTemplate>
</asp:ListView>
</div>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:myConnectionString %>"
SelectCommand="SQL-SELECT-STATEMENT">
</asp:SqlDataSource>
<div>
And jQuery works by taking the link of each item which has the name "Link" and associating it with a dialog box.
<script type="text/javascript">
$(document).ready(function() {
$("a[name=Link]").each(function() {
var $link = $(this);
var $dialog = $('<div></div>')
.load($link.attr('href'))
.dialog({
autoOpen: false,
title: "Edit Article",
width: 500,
height: 550
});
$link.click(function() {
$dialog.dialog('open');
return false;
});
});
});
</script>
Everything worked as it should. Earlier all the records could be shown in one go but as the number of records grew, I needed a paging solution. DataPager for the rescue!
<asp:DataPager ID="DataPager1" runat="server" PagedControlID="ListView1" PageSize="5">
<Fields>
<asp:NextPreviousPagerField />
<asp:NumericPagerField />
</Fields>
</asp:DataPager>
But now the DataPager's controls are not working! I cannot go back,forward or click a page number as it will open the first data bound item's href in the ListView without a dialog box (Just like a normal page). But if i remove the jQuery code, the paging works as it should but I don't get the neat modal dialog box for my editing :(
Any ideas why these cannot exist with each other? Thanx a lot in advance :)
UPDATE: What doesn't work is that they cannot co-exist peacefully. If i remove the jQuery code, the DataPager works fine but I will lost my modal dialog box for editing. If i put the jQuery code back, the modal dialog box works fine but the DataPager doesn't :(
My guess is that link selector is probably selecting data pager links.
You can try $("a[name='Link']").each(.. note single quotes around attribute value.
Alternately, why don't you use id or class selectors. For example:
<a id="editLink" ...
and
$('a#editLink;).each(...
I have Gridview like this:
<asp:GridView ID="gvPartsSearchResult" runat ="server" CssClass="MRJ_TextGrid">
<Columns>
<asp:TemplateField HeaderText="Select">
<ItemTemplate>
<asp:RadioButton
ID="rdButton"
runat="server"
AutoPostBack ="true"
onclick="javascript:CheckOtherIsCheckedByGVIDMore()"/>
<asp:HiddenField
ID="hdnFileExtension"
runat="server"
Value ='<%#Bind("FILE_EXTENSION")%>'/>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
I want to read the hidden field value when the user clicks on the radio button. Can anyone help me with this?
One of the things about ASP.NET that is tough is that the ID's of your controls get mangled, This can make them tough to work with in JavaScript.
ASP.NET 4 offers a new ClientIDMode which eases this pain but until it is released we are stuck using workarounds. I wrote an article explaining the pros and cons of some of these workarounds - hopefully that will get you on the right track.
You could use some jQuery to make your JavaScript more unobtrusive and get rid of your inline event-handler on your radio button:
$(document).ready(function() {
$('table.MRJ_TextGrid input:radio').click(function() {
var hiddenValue = $(this).next().val();
// continue processing...
});
});
iam working on asp.net &c#
i am working on the following scenario.
i have two records ajay and mike in a grid.
requirement:i need a image button to be displayed beside their names such that on clicking the button it will have common functionality for both records.
if i click on the button beside ajay it displays a div with all hyperlinks of ajay
if i click on the button beside mike it displays a div with all hyperlinks of mike
also the button should not be displyed for all the records,it should be displayed only for particular users
can anyone guide me?
You can use ImageButton with TemplateFields to achieve this.
<asp:GridView id="gridview" runat="server">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:ImageButton ID="ImageButton1" runat="server" OnClientClick='OpenDiv(); return false;' />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<script language="javascript" type="text/javascript">
function OpenDiv(){
// do whatever here to open div based on the id
return false;
}
</script>