Video Embede code in Div panel? In Asp.net? - asp.net

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.

Related

Highlight Row - Link button Clicked in RAD grid

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");
});

jQuery selector and DataPager cannot coexist! (ASP .NET)

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(...

Gridview Hidden Field - how can I get a hidden field value using JavaScript?

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...
});
});

image button beside each record in a grid

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>

Asp.Net Image in datalist onclick event? is it possible?

Ok I have been working on this gallery for some time and I keep getting little tidbits. It is now time to finish it off. I have a datalist which binds to an array of *.aspx image urls that contain a thumbnail id that is sent through the url. I now need to implement an onclick event, that when a user clicks on a photo, it brings them to the actual picture.
example url:
(thumbnail) = ~/UserPages/Photo/GetThumbnail.aspx?id=7
(actualpic) = ~/UserPages/Photo/GetPhoto.aspx?id=7
What I need: How do i get it so that each photo has an onclick event? I tried adding onclick to the imag src but it didn't work. It is difficult because it is not an actual image control, they exist inside a datalist. I also need to know how to extract the thumbnail url when getting clicked so that I can grab the id and redirect to the actual picture. Help please!
<asp:DataList ID="dlImages" runat="server"
RepeatColumns="5"
RepeatDirection="Horizontal"
RepeatLayout="Flow">
<ItemTemplate>
<img src="<%# ResolveUrl((string)Container.DataItem) %>" />
</ItemTemplate>
</asp:DataList>
Code Behind:
dlImages.DataSource = ImageUrls;
dlImages.DataBind();
Can you wrap it in an a tag?
<ItemTemplate>
<img src="<%# ResolveUrl(String.Format("~/UserPages/Photo/GetThumbnail.aspx?id={0}", Container.DataItem)) %>" />
</ItemTemplate>
This assumes your DataItem contains only the ID.
Try:
<ItemTemplate>
<img src="<%# ResolveUrl((string)Container.DataItem) %>" onclick="doSomething(this)" />
</ItemTemplate>
After that you can simply implement a doSomething function that parses the id out of "this.src" and do whatever you want with it.

Resources