I have a c# web app that has a calendar - nothing special. The problem I have is that only the numbers can be clicked on and not the entire cell. I've added a onmouseover type handler that makes the cell change color when it's moused over but that's misleading because you can't click on the edge.
Is there any way in asp.net c# that I can make this calendar allow the entire cell to be clickable and not just the hypertext number of the date? I hope I've explained it well enough.
Thanks
<asp:Calendar ID="Calendar1" runat="server"
DayStyle-ForeColor="DarkBlue"
DayHeaderStyle-BackColor="#FEF6CB"
DayStyle-Height="25"
SelectedDayStyle-BackColor="#003F7D"
SelectedDayStyle-ForeColor="White"
DayNameFormat="FirstLetter"
ShowGridLines="true"
BorderColor="Black"
TitleStyle-BackColor="#003F7D"
TitleStyle-ForeColor="White"
TitleStyle-CssClass="CalHeader"
NextPrevStyle-CssClass="CalNextPrev"
NextPrevStyle-ForeColor="White"
OnVisibleMonthChanged="cal_ReserveDate_VisibleMonthChanged"
OnDayRender="cal_ReserveDate_DayRender"
OnSelectionChanged="cal_ReserveDate_SelectionChanged"
DayStyle-BorderColor="Black"
SelectedDayStyle-CssClass="CalendarSelectedDay"
Width="97%" />
UPDATE:
Here is the basic framework of the ascx page:
<%# Control Language="C#" AutoEventWireup="true" CodeFile="BuyTourProductDialogGalaxy2.ascx.cs" Inherits="ConLib_Custom_BuyTourProductDialog2" %>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>
function fixCalendar() {
var a = $('#<%=cal_ReserveDate.ClientID%> a ');
a.contents().wrap("<div/>");
}
</script>
<asp:UpdatePanel ID="upnl_Cal" runat="server" ChildrenAsTriggers="true" UpdateMode="Always">
<ContentTemplate>
<div class="BuyTourProductDialog">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td colspan="2" width="75%">
<asp:Label ID="lblInstructions" runat="server" Text="" EnableViewState="False" CssClass="ReservationInstructions" />
</td>
<td width="25%">
<span style="float: right;">
<asp:Button ID="btn_Reset" runat="server" Text="Reset" OnClick="btn_Reset_Click" Visible="false" CssClass="ResetButton" />
<asp:Button ID="btn_Reserve" runat="server" Text="Reserve" OnClick="btn_Reserve_Click" Visible="true" />
<asp:Button ID="btn_AddToCart" runat="server" Text="Add To Cart" Visible="false" OnClick="btn_AddToCart_Click" />
<asp:Button ID="btn_Continue" runat="server" Text="Continue" Visible="false" OnClick="btn_Continue_Click" />
</span>
</td>
</tr>
</table>
<%-- Calendar Panel --%>
<asp:Panel ID="pnl_GatewayCalendar" runat="server" Visible="false">
<table width="100%">
<%-- Header --%>
<tr>
<td align="center" colspan="2">
<asp:Label ID="lbl_SelectedDate" runat="server" Font-Bold="true" CssClass="SelectedDate" /><br />
</td>
</tr>
<tr>
<%-- Calendar side --%>
<td width="50%" valign="top">
<asp:Calendar ID="cal_ReserveDate" runat="server"
DayStyle-ForeColor="DarkBlue" DayHeaderStyle-BackColor="#FEF6CB" DayStyle-Height="25"
SelectedDayStyle-BackColor="#003F7D" SelectedDayStyle-ForeColor="White"
DayNameFormat="FirstLetter" ShowGridLines="true" BorderColor="Black"
TitleStyle-BackColor="#003F7D" TitleStyle-ForeColor="White" TitleStyle-CssClass="CalHeader"
NextPrevStyle-CssClass="CalNextPrev" NextPrevStyle-ForeColor="White"
OnVisibleMonthChanged="cal_ReserveDate_VisibleMonthChanged"
OnDayRender="cal_ReserveDate_DayRender" OnSelectionChanged="cal_ReserveDate_SelectionChanged"
DayStyle-BorderColor="Black" SelectedDayStyle-CssClass="CalendarSelectedDay" Width="97%" />
</td>
<%-- Event Times side --%>
<td valign="top">
<%-- Another section here for tour times. --%>
</td>
</tr>
</table>
</asp:Panel>
</div>
</ContentTemplate>
</asp:UpdatePanel>
I feel the following links might help you :
http://forums.asp.net/t/1278710.aspx/1
.net calendar - making the whole cell perform postback (clickable)
http://weblogs.sqlteam.com/jhermiz/archive/2007/12/10/Cool-Tricks-With-The-ASP.net-Calendar.aspx
http://forums.asp.net/t/1697353.aspx/1
http://forums.asp.net/t/1216321.aspx/1
The Calendar control doesn't allow you to make the whole cell clickable but you can force it with a little of jQuery if you don't mind using it.
Here's how:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"> </script>
<script>
$(function () {
var a = $('#<%=Calendar1.ClientID%> a');
//wrap the anchor text in a div to force the link to expand
a.contents().wrap("<div/>");
});
</script>
All you need to do is reference jQuery
Update: version for UpdatePanel
Place the following at the top of the page:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>
function fixCalendar() {
var a = $('#<%=cal_ReserveDate.ClientID%> a ');
a.contents().wrap("<div/>");
}
</script>
<asp:ScriptManager ID="scriptManager" runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="updatePanel" runat="server">
<ContentTemplate>
<asp:Calendar ID="cal_ReserveDate" runat="server"
... //etc
Width="97%" />
</ContentTemplate>
</asp:UpdatePanel>
Now, on Page_Load you need to always call the above script as so:
protected void Page_Load(object sender, EventArgs e)
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "key", "fixCalendar();", true);
}
Put this in the body of Default page
<body>
<form id="form1" runat="server">
<table title="mxit:table:full" style="width: 100%;" align="center">
<tr style="background-color: red; text-align: center;">
<td style="width: 25%;">
< Prev
</td>
<td style="width: 50%;">
<asp:Label ID="lblMonth" runat="server"></asp:Label>
<asp:Label ID="lblYear" runat="server"></asp:Label>
<br />
</td>
<td style="width: 25%">
Next >
</td>
</tr>
</table>
<asp:Label ID="lbltest" runat="server" Text=""></asp:Label>
</form>
</body>
Put this in the code Behind Default.aspx.cs
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
try
{
if (Request.QueryString["id"] == "next")
{
if ((int)Session["currentMonth"] >= 12)
{
Session["currentMonth"] = 1;
Session["currentYear"] = (int)Session["currentYear"] + 1;
}
else
{
Session["currentMonth"] = (int)Session["currentMonth"] + 1;
}
DateTime dt = new DateTime((int)Session["currentYear"], (int)(Session["currentMonth"]), 1);
string obj = dt.DayOfWeek.ToString();
GetCalender(obj);
}
else if (Request.QueryString["id"] == "prev")
{
if ((int)Session["currentMonth"] <= 1)
{
Session["currentMonth"] = 12;
Session["currentYear"] = (int)Session["currentYear"] - 1;
}
else
{
Session["currentMonth"] = (int)Session["currentMonth"] - 1;
}
DateTime dt = new DateTime((int)Session["currentYear"], (int)(Session["currentMonth"]), 1);
string obj = dt.DayOfWeek.ToString();
GetCalender(obj);
}
else //this will run when we start the project
{
int currentYear = DateTime.Now.Year;
int currentMonth = DateTime.Now.Month;
Session["currentMonth"] = currentMonth;
Session["currentYear"] = currentYear;
DateTime dt = new DateTime((int)Session["currentYear"], (int)(Session["currentMonth"]), 1);
string obj = dt.DayOfWeek.ToString();
GetCalender(obj);
}
}
catch
{
Response.Redirect("Default.aspx");
}
}
}
private void GetCalender(string obj)
{
try
{
string[] months = new string[] {"January", "February", "March", "April", "May",
"June", "July", "August", "September", "October", "November", "December"};
DayOfWeek objDayofweek = DateTime.Today.Date.DayOfWeek;
lbltest.Text = "<table style='width:100%' align='center'><colgroup span='7' style='width:15%'></colgroup><tr><td>Mon</td>";
lbltest.Text = lbltest.Text + "<td>Tue</td>";
lbltest.Text = lbltest.Text + "<td>Wed</td>";
lbltest.Text = lbltest.Text + "<td>Thu</td>";
lbltest.Text = lbltest.Text + "<td>Fri</td>";
lbltest.Text = lbltest.Text + "<td>Sat</td>";
lbltest.Text = lbltest.Text + "<td>Sun</td></tr><tr>";
int y = 1;
switch (obj.ToString())
{
case "Monday":
y = 1;
break;
case "Tuesday":
lbltest.Text = lbltest.Text + "<td> </td>";
y = 2;
break;
case "Wednesday":
lbltest.Text = lbltest.Text + "<td> </td>";
lbltest.Text = lbltest.Text + "<td> </td>";
y = 3;
break;
case "Thursday":
lbltest.Text = lbltest.Text + "<td> </td>";
lbltest.Text = lbltest.Text + "<td> </td>";
lbltest.Text = lbltest.Text + "<td> </td>";
y = 4;
break;
case "Friday":
lbltest.Text = lbltest.Text + "<td> </td>";
lbltest.Text = lbltest.Text + "<td> </td>";
lbltest.Text = lbltest.Text + "<td> </td>";
lbltest.Text = lbltest.Text + "<td> </td>";
y = 5;
break;
case "Saturday":
lbltest.Text = lbltest.Text + "<td> </td>";
lbltest.Text = lbltest.Text + "<td> </td>";
lbltest.Text = lbltest.Text + "<td> </td>";
lbltest.Text = lbltest.Text + "<td> </td>";
lbltest.Text = lbltest.Text + "<td> </td>";
y = 6;
break;
case "Sunday":
lbltest.Text = lbltest.Text + "<td> </td>";
lbltest.Text = lbltest.Text + "<td> </td>";
lbltest.Text = lbltest.Text + "<td> </td>";
lbltest.Text = lbltest.Text + "<td> </td>";
lbltest.Text = lbltest.Text + "<td> </td>";
lbltest.Text = lbltest.Text + "<td> </td>";
y = 7;
break;
}
for (int dayday = Convert.ToInt32(objDayofweek); dayday <= DateTime.DaysInMonth((int)Session["currentYear"], (int)(Session["currentMonth"])); dayday++)
{
if (y < 7)
{
lbltest.Text = lbltest.Text + "<td><a href='#Date=" + dayday.ToString() + "/" + Session["currentMonth"] + "/" + Session["currentYear"] + "'>" + dayday.ToString() + "</a></td>";
y++;
}
else
{
lbltest.Text = lbltest.Text + "<td><a href='#Date=" + dayday.ToString() + "/" + Session["currentMonth"] + "/" + Session["currentYear"] + "'>" + dayday.ToString() + "</a></td>";
y = 1;
lbltest.Text = lbltest.Text + "</tr><tr>";
}
}
lbltest.Text = lbltest.Text + "</tr></table>";
lblMonth.Text = months[(int)Session["currentMonth"] - 1].ToString();
lblYear.Text = Session["currentYear"].ToString();
}
catch
{
Response.Redirect("Default.aspx");
}
}
}
Related
How to fix code have select all asp:CheckBoxList within current table only in .NET C# same as "JQuery - Select All CheckBoxes within current table only" question ?
Because I try coding with sample but can't select all asp:CheckBoxList within current table only.
Link to "JQuery - Select All CheckBoxes within current table only" question.
My snipplet to describe problem.
<!DOCTYPE html>
<html>
<head>
<script
type="text/javascript"
src="//code.jquery.com/jquery-1.6.4.js"></script>
<style>
form , p , td, th{
font-size: 24px;
}
input.largerCheckbox
{
width: 22px;
height: 22px;
}
</style>
</head>
<body>
<h1>Show checkboxes:</h1>
<p><label><input type="checkbox" class="largerCheckbox" id="checkAll"/> Check all</label></p>
<input type="text" id="myInput" onkeyup="myFunction()" placeholder="Search for names.." title="Type in a name"><br><br>
<table id="myTable">
<tr class="header">
<th>Checkbox</th>
<th>Number</th>
</tr>
<tr>
<td><input type="checkbox" class="largerCheckbox" name="vehicle1" value="1"></td>
<td>1</td>
</tr>
<tr>
<td><input type="checkbox" class="largerCheckbox" name="vehicle2" value="11"></td>
<td>11</td>
</tr>
<tr>
<td><input type="checkbox" class="largerCheckbox" name="vehicle3" value="111"></td>
<td>111</td>
</tr>
<tr>
<td><input type="checkbox" class="largerCheckbox" name="vehicle4" value="1111"></td>
<td>1111</td>
</tr>
<tr>
<td><input type="checkbox" class="largerCheckbox" name="vehicle5" value="11111"></td>
<td>11111</td>
</tr>
</table>
<script>
function myFunction() {
var input, filter, table, tr, td, i, txtValue;
input = document.getElementById("myInput");
filter = input.value.toUpperCase();
table = document.getElementById("myTable");
tr = table.getElementsByTagName("tr");
for (i = 0; i < tr.length; i++) {
td = tr[i].getElementsByTagName("td")[1];
if (td) {
txtValue = td.textContent || td.innerText;
if (txtValue.toUpperCase().indexOf(filter) > -1) {
tr[i].style.display = "";
} else {
tr[i].style.display = "none";
}
}
}
}
</script>
<script>
$("#checkAll").change(function () {
$("input:checkbox").prop('checked', $(this).prop("checked"));
});
</script>
</body>
</html>
My full source code.
https://github.com/doanga2007/CheckLoopQR3
Sample code at the bottom.
Default.aspx (HTML Code)
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="CheckLoopQR3.Default" %>
<!DOCTYPE html>
<html>
<head runat="server">
<title></title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script type="text/javascript" src="//code.jquery.com/jquery-1.6.4.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<style>
#myInput {
font-size: 16px;
padding: 6px 20px 6px 10px;
border: 1px solid #ddd;
margin-bottom: 3px;
}
</style>
<script type="text/javascript">
$(window).load(function(){
$("#checkAll").change(function () {
$("input:checkbox").prop('checked', $(this).prop("checked"));
});
});
</script>
<script>
function myFunction() {
var input, filter, table, tr, td, i, txtValue;
input = document.getElementById("myInput");
filter = input.value.toUpperCase();
table = document.getElementById("CheckBox1");
tr = table.getElementsByTagName("tr");
for (i = 0; i < tr.length; i++) {
td = tr[i].getElementsByTagName("td")[0];
if (td) {
txtValue = td.textContent || td.innerText;
if (txtValue.toUpperCase().indexOf(filter) > -1) {
tr[i].style.display = "";
} else {
tr[i].style.display = "none";
}
}
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div class="container">
<h2>QR Code Generator</h2>
<div class="row">
<div class="col-md-4">
<div class="form-group">
<label>Please Input Data</label>
<div class="input-group">
<asp:TextBox ID="txtQRCode" runat="server" CssClass="form-control"></asp:TextBox>
<div class="input-group-prepend">
<asp:Button ID="btnGenerate" runat="server" CssClass="btn btn-secondary" Text="Generate" OnClick="btnGenerate_Click" />
</div>
</div>
</div>
</div>
</div>
<asp:Button ID="btnSelect" runat="server" CssClass="btn btn-secondary" Text="Display Text" OnClick="btnSelect_Click" /><br /><br />
<asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>
<asp:CheckBox ID="checkAll" runat="server" Font-Size="Large"/><asp:Label id="checkTextAll" runat="server" Font-Size="Large"></asp:Label><br /><br />
<label>Input Number to Search </label>
<input type="text" id="myInput" onkeyup="myFunction()"><br /><br />
<asp:CheckBoxList ID="CheckBox1" runat="server" Border="1"
BorderColor="LightGray" Font-Size="Large"></asp:CheckBoxList>
</div>
</form>
</body>
</html>
Default.aspx.cs (C# Code)
using System;
using System.Drawing;
using System.IO;
using ZXing;
using ZXing.QrCode;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace CheckLoopQR3
{
public partial class Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
this.checkTextAll.Text = " Check All";
}
protected void btnSelect_Click(object sender, EventArgs e)
{
string code = txtQRCode.Text;
long num = Convert.ToInt64(code);
int i;
for (i = 1; i < 6; i++)
{
num *= i;
CheckBox1.Items.Add(new ListItem(" " + num));
}
}
protected void btnGenerate_Click(object sender, EventArgs e)
{
if (CheckBox1.SelectedItem == null)
{
Response.Redirect("Default.aspx");
}
string[] texture = { "Selected Text 1 -> ", "Selected Text 2 -> ", "Selected Text 3 -> ",
"Selected Text 4 -> ", "Selected Text 5 -> "};
string[] texture2 = { " is Checkbox 1.", " is Checkbox 2.", " is Checkbox 3.",
" is Checkbox 4.", " is Checkbox 5."};
foreach (ListItem listItem in CheckBox1.Items)
{
if (listItem.Selected)
{
int a = CheckBox1.Items.IndexOf(listItem);
a = a + 1;
string code = listItem.Text;
CheckBox1.Visible = false;
checkAll.Visible = false;
checkTextAll.Visible = false;
QrCodeEncodingOptions options = new QrCodeEncodingOptions();
options = new QrCodeEncodingOptions
{
DisableECI = true,
CharacterSet = "UTF-8",
Width = 150,
Height = 150,
Margin = 0,
};
var barcodeWriter = new BarcodeWriter();
barcodeWriter.Format = BarcodeFormat.QR_CODE;
barcodeWriter.Options = options;
System.Web.UI.WebControls.Image imgBarCode = new System.Web.UI.WebControls.Image();
imgBarCode.Height = 150;
imgBarCode.Width = 150;
Label lblvalues = new Label();
lblvalues.Text += texture[a - 1] + listItem.Text + texture2[a - 1];
lblvalues.Font.Size = FontUnit.Large;
using (Bitmap bitMap = barcodeWriter.Write(code))
{
using (MemoryStream ms = new MemoryStream())
{
bitMap.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
byte[] byteImage = ms.ToArray();
imgBarCode.ImageUrl = "data:image/png;base64," + Convert.ToBase64String(byteImage);
}
PlaceHolder1.Controls.Add(imgBarCode);
PlaceHolder1.Controls.Add(new HtmlGenericControl("br"));
PlaceHolder1.Controls.Add(lblvalues);
PlaceHolder1.Controls.Add(new HtmlGenericControl("br"));
}
}
else
{
//do something else
}
}
}
}
}
Good news : I have answer to fix code have select all asp:CheckBoxList within current table only in .NET C# same as "JQuery - Select All CheckBoxes within current table only" question.
Key of answer to "jQuery :visible Selector".
jQuery :
$(window).load(function(){
$("#checkAll").change(function () {
$("input:checkbox:visible").prop('checked', $(this).prop("checked"));
});
});
My snipplet to another solve problem in HTML.
<!DOCTYPE html>
<html>
<head>
<script
type="text/javascript"
src="//code.jquery.com/jquery-1.6.4.js"></script>
<style>
form , p , td, th{
font-size: 24px;
}
input.largerCheckbox
{
width: 22px;
height: 22px;
}
</style>
</head>
<body>
<h1>Show checkboxes:</h1>
<p><label><input type="checkbox" class="largerCheckbox" id="checkAll"/> Check all</label></p>
<input type="text" id="myInput" onkeyup="myFunction()" placeholder="Search for names.." title="Type in a name"><br><br>
<table id="myTable">
<tr class="header">
<th>Checkbox</th>
<th>Number</th>
</tr>
<tr>
<td><input type="checkbox" class="largerCheckbox" name="vehicle1" value="1"></td>
<td>1</td>
</tr>
<tr>
<td><input type="checkbox" class="largerCheckbox" name="vehicle2" value="11"></td>
<td>11</td>
</tr>
<tr>
<td><input type="checkbox" class="largerCheckbox" name="vehicle3" value="111"></td>
<td>111</td>
</tr>
<tr>
<td><input type="checkbox" class="largerCheckbox" name="vehicle4" value="1111"></td>
<td>1111</td>
</tr>
<tr>
<td><input type="checkbox" class="largerCheckbox" name="vehicle5" value="11111"></td>
<td>11111</td>
</tr>
</table>
<script>
function myFunction() {
var input, filter, table, tr, td, i, txtValue;
input = document.getElementById("myInput");
filter = input.value.toUpperCase();
table = document.getElementById("myTable");
tr = table.getElementsByTagName("tr");
for (i = 0; i < tr.length; i++) {
td = tr[i].getElementsByTagName("td")[1];
if (td) {
txtValue = td.textContent || td.innerText;
if (txtValue.toUpperCase().indexOf(filter) > -1) {
tr[i].style.display = "";
} else {
tr[i].style.display = "none";
}
}
}
}
</script>
<script>
$("#checkAll").change(function () {
$("input:checkbox:visible").prop('checked', $(this).prop("checked"));
});
</script>
</body>
</html>
My full source code.
https://github.com/doanga2007/CheckLoopQR3
Default.aspx (HTML Code)
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="CheckLoopQR3.Default" %>
<!DOCTYPE html>
<html>
<head runat="server">
<title></title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script type="text/javascript" src="//code.jquery.com/jquery-1.6.4.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<style>
#myInput {
font-size: 16px;
padding: 6px 20px 6px 10px;
border: 1px solid #ddd;
margin-bottom: 3px;
}
</style>
<script type="text/javascript">
$(window).load(function(){
$("#checkAll").change(function () {
$("input:checkbox:visible").prop('checked', $(this).prop("checked"));
});
});
</script>
<script>
function myFunction() {
var input, filter, table, tr, td, i, txtValue;
input = document.getElementById("myInput");
filter = input.value.toUpperCase();
table = document.getElementById("CheckBox1");
tr = table.getElementsByTagName("tr");
for (i = 0; i < tr.length; i++) {
td = tr[i].getElementsByTagName("td")[0];
if (td) {
txtValue = td.textContent || td.innerText;
if (txtValue.toUpperCase().indexOf(filter) > -1) {
tr[i].style.display = "";
} else {
tr[i].style.display = "none";
}
}
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div class="container">
<h2>QR Code Generator</h2>
<div class="row">
<div class="col-md-4">
<div class="form-group">
<label>Please Input Data</label>
<div class="input-group">
<asp:TextBox ID="txtQRCode" runat="server" CssClass="form-control"></asp:TextBox>
<div class="input-group-prepend">
<asp:Button ID="btnGenerate" runat="server" CssClass="btn btn-secondary" Text="Generate" OnClick="btnGenerate_Click" />
</div>
</div>
</div>
</div>
</div>
<label>Input Number to Search </label>
<input type="text" id="myInput" onkeyup="myFunction()"><br />
<asp:Button ID="btnSelect" runat="server" CssClass="btn btn-secondary" Text="Display Text" OnClick="btnSelect_Click" /><br /><br />
<asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>
<asp:CheckBox ID="checkAll" runat="server" Font-Size="Large"/><asp:Label id="checkTextAll" runat="server" Font-Size="Large"></asp:Label><br /><br />
<asp:CheckBoxList ID="CheckBox1" runat="server" Border="1"
BorderColor="LightGray" Font-Size="Large"></asp:CheckBoxList>
</div>
</form>
</body>
</html>
Default.aspx.cs (C# Code)
using System;
using System.Drawing;
using System.IO;
using ZXing;
using ZXing.QrCode;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace CheckLoopQR3
{
public partial class Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
this.checkTextAll.Text = " Check All";
}
protected void btnSelect_Click(object sender, EventArgs e)
{
string code = txtQRCode.Text;
long num = Convert.ToInt64(code);
int i;
for (i = 1; i < 6; i++)
{
num *= i;
CheckBox1.Items.Add(new ListItem(" " + num));
}
}
protected void btnGenerate_Click(object sender, EventArgs e)
{
if (CheckBox1.SelectedItem == null)
{
Response.Redirect("Default.aspx");
}
string[] texture = { "Selected Text 1 -> ", "Selected Text 2 -> ", "Selected Text 3 -> ",
"Selected Text 4 -> ", "Selected Text 5 -> "};
string[] texture2 = { " is Checkbox 1.", " is Checkbox 2.", " is Checkbox 3.",
" is Checkbox 4.", " is Checkbox 5."};
foreach (ListItem listItem in CheckBox1.Items)
{
if (listItem.Selected)
{
int a = CheckBox1.Items.IndexOf(listItem);
a = a + 1;
string code = listItem.Text;
CheckBox1.Visible = false;
checkAll.Visible = false;
checkTextAll.Visible = false;
QrCodeEncodingOptions options = new QrCodeEncodingOptions();
options = new QrCodeEncodingOptions
{
DisableECI = true,
CharacterSet = "UTF-8",
Width = 150,
Height = 150,
Margin = 0,
};
var barcodeWriter = new BarcodeWriter();
barcodeWriter.Format = BarcodeFormat.QR_CODE;
barcodeWriter.Options = options;
System.Web.UI.WebControls.Image imgBarCode = new System.Web.UI.WebControls.Image();
imgBarCode.Height = 150;
imgBarCode.Width = 150;
Label lblvalues = new Label();
lblvalues.Text += texture[a - 1] + listItem.Text + texture2[a - 1];
lblvalues.Font.Size = FontUnit.Large;
using (Bitmap bitMap = barcodeWriter.Write(code))
{
using (MemoryStream ms = new MemoryStream())
{
bitMap.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
byte[] byteImage = ms.ToArray();
imgBarCode.ImageUrl = "data:image/png;base64," + Convert.ToBase64String(byteImage);
}
PlaceHolder1.Controls.Add(imgBarCode);
PlaceHolder1.Controls.Add(new HtmlGenericControl("br"));
PlaceHolder1.Controls.Add(lblvalues);
PlaceHolder1.Controls.Add(new HtmlGenericControl("br"));
}
}
else
{
//do something else
}
}
}
}
}
After saving information from a page in c# net 4.0 I need to add some pics in multiple mode.
I can't use net 4.5.
The problem :
If I open the page with multiple upload in the browser IE 11 this works correctly, and you can select multiple pics to upload.
If I open the same page as multiple upload in a window popup on IE 11, you can't select multiple pics to upload, but only a pic.
What's the problem ?
My code below, thank you in advance.
.aspx markup (Default.aspx)
<form id="form1" runat="server">
<div>
<asp:Panel ID="upload01" runat="server" CssClass="pure-form pure-form-stacked">
<fieldset style="margin-left: 50px">
<legend style="font-weight: bold; color: Red; margin-left: 10px;">PICS</legend>
<div class="pure-g">
<div class="pure-u-1 pure-u-md-1-3">
<label for="Pics">Pics</label>
<p>
<asp:FileUpload ID="fileUpload" multiple="true" runat="server" />
</p>
<p>
<p>
<asp:Button ID="btUpload" Text="Upload Files"
OnClick="Upload_Files" runat="server" />
</p>
</p>
<p>
<asp:Label ID="lblFileList" runat="server"></asp:Label>
</p>
<p>
<asp:Label ID="lblUploadStatus" runat="server"></asp:Label>
</p>
<p>
<asp:Label ID="lblFailedStatus" runat="server"></asp:Label>
</p>
</div>
</div>
</fieldset>
</asp:Panel>
</div>
</form>
.cs code-behind
protected void btnSave_Click(object sender, ImageClickEventArgs e)
{
ScriptManager.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW", "var Mleft = (screen.width/2)-(760/2);var Mtop = (screen.height/2)-(700/2);window.open( 'Default.aspx', null, 'height=700,width=760,status=yes,toolbar=no,scrollbars=yes,menubar=no,location=no,top=\'+Mtop+\', left=\'+Mleft+\'' );", true);
}
EDIT #1
protected void Upload_Files(object sender, EventArgs e)
{
if (upload01.HasFile) // CHECK IF ANY FILE HAS BEEN SELECTED.
{
int iUploadedCnt = 0;
int iFailedCnt = 0;
HttpFileCollection hfc = Request.Files;
lblFileList.Text = "Select <b>" + hfc.Count + "</b> file(s)";
if (hfc.Count <= 10) // 10 FILES RESTRICTION.
{
for (int i = 0; i <= hfc.Count - 1; i++)
{
HttpPostedFile hpf = hfc[i];
if (hpf.ContentLength > 0)
{
if (!File.Exists(Server.MapPath("\\images\\") +
Path.GetFileName(hpf.FileName)))
{
DirectoryInfo objDir =
new DirectoryInfo(Server.MapPath("\\images\\"));
string sFileName = Path.GetFileName(hpf.FileName);
string sFileExt = Path.GetExtension(hpf.FileName);
// CHECK FOR DUPLICATE FILES.
FileInfo[] objFI =
objDir.GetFiles(sFileName.Replace(sFileExt, "") + ".*");
if (objFI.Length > 0)
{
// CHECK IF FILE WITH THE SAME NAME EXISTS (IGNORING THE EXTENTIONS).
foreach (FileInfo file in objFI)
{
string sFileName1 = objFI[0].Name;
string sFileExt1 = Path.GetExtension(objFI[0].Name);
if (sFileName1.Replace(sFileExt1, "") ==
sFileName.Replace(sFileExt, ""))
{
iFailedCnt += 1; // NOT ALLOWING DUPLICATE.
break;
}
}
}
else
{
// SAVE THE FILE IN A FOLDER.
hpf.SaveAs(Server.MapPath("\\images\\") +
Path.GetFileName(hpf.FileName));
iUploadedCnt += 1;
}
}
}
}
lblUploadStatus.Text = "<b>" + iUploadedCnt + "</b> file(s) Uploaded.";
lblFailedStatus.Text = "<b>" + iFailedCnt +
"</b> duplicate file(s) could not be uploaded.";
}
else lblUploadStatus.Text = "Max. 10 files allowed.";
}
else lblUploadStatus.Text = "No files selected.";
}
I think your approach is wrong for this problem
Please see this, I hope this help.
Click here
I am exporting a pdf from a json string from database. My export buttons are in a gridview control - Image buttons. I am using a Handler (ashx) file for exporting.
The problem is, after exporting the buttons on the page (one button and one command field) are not posting back. My handler code and aspx code are below
Handler
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI.WebControls;
using iTextSharp.text;
using iTextSharp.text.pdf;
using iTextSharp.text.html;
using iTextSharp.text.html.simpleparser;
using System.IO;
using System.Web.UI;
using System.Data;
using GE.MSA.DataQuality.DataAccess;
using GE.MSA.DataQuality.DataAccess.Authentication;
using GE.MSA.DataQuality.DataAccess.EntityModel;
using Newtonsoft.Json;
namespace GE.MSA.DataQuality.Web
{
/// <summary>
/// Summary description for CreatePDF
/// </summary>
public class CreatePDF : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
//context.Response.ContentType = "text/plain";
//context.Response.Write("Hello World");
int _id = Convert.ToInt32(context.Request.QueryString["Id"]);
string _report = context.Request.QueryString["Report"];
string _lockedfrom = context.Request.QueryString["LockedFrom"];
string _lockedto = context.Request.QueryString["LockedTo"];
string _docheader = (_report == "CostServiceReport" ? "Cost & Service Report - " : "Service Report - ") + "Locked from : " + _lockedfrom + " to " + _lockedto;
string _doctitle = _report + "-" + _lockedfrom + "-" + _lockedto + ".pdf";
DataTable _PDFReport = new DataTable();
if (_report == "CostServiceReport")
{
using (var db = new dbReferenceTablesEntities())
{
string csr = (from i in db.CS_Billing_LockPeriod
where i.ID == _id
select i.CostServiceReport).FirstOrDefault().ToString();
_PDFReport = (DataTable)JsonConvert.DeserializeObject(csr, _PDFReport.GetType());
}
}
else
{
if (_report == "ServiceReport")
{
using (var db = new dbReferenceTablesEntities())
{
string sr = (from i in db.CS_Billing_LockPeriod
where i.ID == _id
select i.ServiceReport).FirstOrDefault().ToString();
_PDFReport = (DataTable)JsonConvert.DeserializeObject(sr, _PDFReport.GetType());
}
}
}
Document pdfDoc = new Document(PageSize.A3, 20, 20, 20, 20);
pdfDoc.SetPageSize(iTextSharp.text.PageSize.A3.Rotate());
try
{
PdfWriter.GetInstance(pdfDoc, System.Web.HttpContext.Current.Response.OutputStream);
pdfDoc.Open();
Chunk c = new Chunk("" + _docheader + "", FontFactory.GetFont("Verdana", 15));
Paragraph p = new Paragraph();
p.Alignment = Element.ALIGN_CENTER;
p.Add(c);
pdfDoc.Add(p);
string clientLogo = context.Server.MapPath(".") + "/images/abc.png";
string imageFilePath = context.Server.MapPath(".") + "/images/abc.png";
iTextSharp.text.Image jpg = iTextSharp.text.Image.GetInstance(imageFilePath);
//Resize image depend upon your need
jpg.ScaleToFit(60f, 40f);
//Give space before image
jpg.SpacingBefore = 0f;
//Give some space after the image
jpg.SpacingAfter = 1f;
jpg.Alignment = Element.HEADER;
pdfDoc.Add(jpg);
Font font8 = FontFactory.GetFont("ARIAL", 7);
DataTable dt = _PDFReport;
if (dt != null & dt.Rows.Count > 0)
{
//Craete instance of the pdf table and set the number of column in that table
PdfPTable PdfTable = new PdfPTable(dt.Columns.Count);
PdfTable.HeaderRows = 1;
PdfPCell PdfPCell = null;
for (int i = 0; i < dt.Columns.Count; i++)
{
PdfPCell = new PdfPCell(new Phrase(new Chunk(dt.Columns[i].ColumnName.ToString(), FontFactory.GetFont("Verdana", 12))));
PdfPCell.HorizontalAlignment = Element.ALIGN_CENTER;
PdfPCell.VerticalAlignment = Element.ALIGN_MIDDLE;
PdfPCell.BackgroundColor = new Color(109, 159, 213);
PdfTable.AddCell(PdfPCell);
}
for (int rows = 0; rows < dt.Rows.Count; rows++)
{
for (int column = 0; column < dt.Columns.Count; column++)
{
PdfPCell = new PdfPCell(new Phrase(new Chunk(dt.Rows[rows][column].ToString(), font8)));
PdfTable.AddCell(PdfPCell);
}
}
//PdfTable.SpacingBefore = 15f; // Give some space after the text or it may overlap the table
pdfDoc.Add(PdfTable); // add pdf table to the document
}
pdfDoc.Close();
context.Response.ContentType = "application/pdf";
context.Response.AddHeader("content-disposition", "attachment; filename= " + _doctitle);
System.Web.HttpContext.Current.Response.Write(pdfDoc);
context.Response.Flush();
HttpContext.Current.ApplicationInstance.CompleteRequest();
}
catch (DocumentException de)
{
System.Web.HttpContext.Current.Response.Write(de.Message);
}
catch (IOException ioEx)
{
System.Web.HttpContext.Current.Response.Write(ioEx.Message);
}
catch (Exception ex)
{
System.Web.HttpContext.Current.Response.Write(ex.Message);
}
}
public bool IsReusable
{
get
{
return false;
}
}
}
}
ASPX Page
<%# Page Title="" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" CodeBehind="LockForcing.aspx.cs" Inherits="GE.MSA.DataQuality.Web.LockForcing" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<asp:ScriptManager ID="scriptManager1" runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="up1" runat="server">
<ContentTemplate>
<h2>Lock Force Calculation</h2>
<div>
<fieldset>
<legend>Set Lock Period</legend>
<table>
<tr>
<td>
<label>Start Month</label></td>
<td>
<asp:DropDownList ID="ddlStartMonth" runat="server" Width="100%">
<asp:ListItem>01</asp:ListItem>
<asp:ListItem>02</asp:ListItem>
<asp:ListItem>03</asp:ListItem>
<asp:ListItem>04</asp:ListItem>
<asp:ListItem>05</asp:ListItem>
<asp:ListItem>06</asp:ListItem>
<asp:ListItem>07</asp:ListItem>
<asp:ListItem>08</asp:ListItem>
<asp:ListItem>09</asp:ListItem>
<asp:ListItem>10</asp:ListItem>
<asp:ListItem>11</asp:ListItem>
<asp:ListItem>12</asp:ListItem>
</asp:DropDownList></li></td>
<td></td>
<td>
<label>Start Year</label></td>
<td>
<asp:DropDownList ID="ddlStartYear" runat="server" Width="100%">
</asp:DropDownList></td>
</tr>
<tr>
<td>
<label>End Month</label></td>
<td>
<asp:DropDownList ID="ddlEndMonth" runat="server" Width="100%">
<asp:ListItem>01</asp:ListItem>
<asp:ListItem>02</asp:ListItem>
<asp:ListItem>03</asp:ListItem>
<asp:ListItem>04</asp:ListItem>
<asp:ListItem>05</asp:ListItem>
<asp:ListItem>06</asp:ListItem>
<asp:ListItem>07</asp:ListItem>
<asp:ListItem>08</asp:ListItem>
<asp:ListItem>09</asp:ListItem>
<asp:ListItem>10</asp:ListItem>
<asp:ListItem>11</asp:ListItem>
<asp:ListItem>12</asp:ListItem>
</asp:DropDownList></td>
<td></td>
<td>
<label>End Year</label></td>
<td>
<asp:DropDownList ID="ddlEndYear" runat="server" Width="100%">
</asp:DropDownList></td>
<td>
<asp:Button ID="btnLock" runat="server" Width="120px" Text="Lock" CssClass="submitButton"
BorderStyle="None" OnClick="btnLock_Click" />
</td>
<td>
<asp:Label runat="server" ID="lblLockMessage"></asp:Label>
<asp:Timer ID="Timer1" runat="server" Interval="5000" Enabled="false" OnTick="Timer1_Tick"></asp:Timer>
</td>
</tr>
</table>
</fieldset>
</div>
<div>
<table width="100%">
<tr>
<td>
<label>Lock Period Details</label>
</td>
<td align="right">
<asp:Label runat="server" ID="lblmsg"></asp:Label>
</td>
</tr>
<tr>
<td colspan="2">
<asp:GridView ID="gvLockPeriod" runat="server" AutoGenerateColumns="false" CssClass="mGrid" OnRowDeleting="gvLockPeriod_RowDeleting"
DataKeyNames="Id">
<Columns>
<asp:CommandField ShowDeleteButton="true" ControlStyle-ForeColor="darkcyan" DeleteText="Unlock"></asp:CommandField>
<asp:BoundField DataField="FromDate" HeaderText="FromDate" />
<asp:BoundField DataField="ToDate" HeaderText="ToDate" />
<asp:TemplateField HeaderText="Cost&ServiceReport">
<ItemTemplate>
<asp:ImageButton ImageUrl="~/images/Pdf-16.png" runat="server" ToolTip="Download Cost & Service Report"
Visible='<%# Convert.ToBoolean(Eval("CostServiceReport")) %>'
PostBackUrl='<%#"CreatePDF.ashx?id="+Eval("Id")+"&Report=CostServiceReport"+"&LockedFrom="+Eval("fromdate")+"&LockedTo="+Eval("todate")+""%>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="ServiceReport">
<ItemTemplate>
<asp:ImageButton ImageUrl="~/images/Pdf-16.png" runat="server" ToolTip="Download Service Report"
Visible='<%# Convert.ToBoolean(Eval("ServiceReport")) %>'
PostBackUrl='<%#"CreatePDF.ashx?id="+Eval("Id")+"&Report=ServiceReport"+"&LockedFrom="+Eval("fromdate")+"&LockedTo="+Eval("todate")+""%>' />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="ModifiedBy" HeaderText="CreatedUser" />
<asp:BoundField DataField="ModifiedDate" HeaderText="CreatedDate" />
</Columns>
</asp:GridView>
</td>
</tr>
</table>
</div>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdateProgress ID="UpdateProgress1" runat="server">
<ProgressTemplate>
<div class="overlays" />
<div style="font-weight: bold; align-content: center" class="overlayContents">
<asp:Image ID="aspImg1" runat="server" ImageUrl="~/images/ajax-loader.GIF" />
</div>
</ProgressTemplate>
</asp:UpdateProgress>
</asp:Content>
After flushing the response call the response end method.
context.Response.Flush();
System.Web.HttpContext.Current.Response.End();
I have a sitecore web part that I am trying to get to display the top 2 most current items by date. I am having trouble because I am only able to get the latest item to show.
For the ascx Code:
<asp:Repeater ID="newsContainer" runat="server">
<ItemTemplate>
<div class="newsItem">
<h2>News</h2>
<a href="<%# SitecoreUtility.NavigateUrl((Item)Container.DataItem)%>" class="newsHeadline">
<span> <sc:Date ID="Date1" Item="<%# Container.DataItem %>" Field="Posted-Date" Format="MM.dd.yyyy" runat="server" />
<sc:Text ID="Text1" Item="<%# Container.DataItem %>" Field="Title" runat="server" />
</span>
</a>
<!-- <p class="newsSummary">
<asp:Literal ID="litBody" runat="server" Text="<%# SitecoreUtility.TruncateByWords(((Item)Container.DataItem).Fields[Constants.Fields.BODY].Value, 20) %>"></asp:Literal>
...
+ More</p> -->
</div>
</ItemTemplate>
</asp:Repeater>
<asp:Panel ID="pnlPagination" runat="server"></asp:Panel>
<asp:Panel ID="pnlArchive" runat="server">
<!-- <div class="newsArchiveLink">
View Archived News
</div> -->
</asp:Panel>
<asp:Panel ID="pnlCurrent" runat="server">
<div class="newsArchiveLink">
View Current News
</div>
</asp:Panel>
For the ASCX.CS File:
public partial class Homepage_NewsListing : BaseSublayout
{
int CurrentPage = 1;
int PageSize = Constants.Values.SEARCH_SMALL_LIST;
protected void Page_Load(object sender, EventArgs e)
{
CurrentPage = int.Parse(WebUtil.GetQueryString("page", "1"));
List<Item> newsListings = new List<Item>();
Item newsItems = SitecoreUtility.Db.GetItem(Constants.Items.NEWS);
if (WebUtil.GetQueryString("type", "") == "archive")
{
newsListings = newsItems.Children.Where(item =>
(SitecoreUtility.FormatDateAtMidnight(item, Constants.Fields.ARCHIVEDATE) <= DateTime.Now)
&&
(!string.IsNullOrEmpty(item.Fields[Constants.Fields.ARCHIVEDATE].Value))
).OrderBy(item => item.Fields[Constants.Fields.POSTED_DATE].Value).ToList();
pnlArchive.Visible = false;
//pnlCurrent.Visible = true;
pnlCurrent.Visible = false;
}
else
{
newsListings = newsItems.Children.Where(item =>
(SitecoreUtility.FormatDateAtMidnight(item, Constants.Fields.ARCHIVEDATE) > DateTime.Now)
||
(string.IsNullOrEmpty(item.Fields[Constants.Fields.ARCHIVEDATE].Value))
).OrderBy(item => item.Fields[Constants.Fields.POSTED_DATE].Value).ToList();
//pnlArchive.Visible = true;
pnlArchive.Visible = false;
pnlCurrent.Visible = false;
}
newsContainer.DataSource = DisplayResults(newsListings.OrderByDescending(item => item.Fields[Constants.Fields.POSTED_DATE].Value).ToList());
newsContainer.DataBind();
}
protected List<Item> DisplayResults(List<Item> results)
{
pnlPagination.Controls.Add(new Pager(results.Count, PageSize, CurrentPage).BuildPaging());
if (CurrentPage > 1)
return results.Skip((CurrentPage - 1) * PageSize).Take(PageSize).ToList();
return results.Take(PageSize).ToList();
}
}
I would first try to make your code a bit more simple (for debugging) and use a fast query to pull items within a date range.
var date = DateTime.Now.AddMonths(3);
var dateString = date.Year.ToString() + date.Month.ToString().PadLeft(2, '0') + date.Day.ToString().PadLeft(2, '0');
var newsList = Sitecore.Context.Database.SelectItems("fast:/sitecore/content/home/your-path-to-news/*[##templatename='Your template name' and #POSTED_DATE > '" + dateString + "']").ToList();
newsList = newsList.OrderByDescending(n => n.Fields["POSTED_DATE"].Value).Take(2).ToList();
newsContainer.DataSource = newsList;
newsContainer.DataBind();
I want to convert from wmv to mp4, webm and ogv on upload.
is there a way to implement miro video converter or something like at codebehind?
what i use is ACT's AsyncUpload
aspx page
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="Server">
<script type="text/javascript">
function uploadError(sender, args) {
if (document.getElementById('<%=lblStatus.ClientID%>').innerText.indexOf('must be a video') == -1)
document.getElementById('<%=lblStatus.ClientID%>').innerText = "Upload error!", "<span style='color:red;'>" + args.get_errorMessage() + "</span>";
}
function StartUpload(sender, args) {
document.getElementById('<%=lblStatus.ClientID%>').innerText = 'Uploading';
}
function UploadComplete(sender, args) {
var filename = args.get_fileName();
var contentType = args.get_contentType();
if (contentType.indexOf('video') == -1) {
document.getElementById('<%=lblStatus.ClientID%>').innerText = "Uploaded file must be a video!", "<span style='color:red;'>" + args.get_errorMessage() + "</span>";
document.getElementById('<%=AsyncFileUpload1.ClientID%>').text.style.backgroundColor = "Red";
}
else {
var text = "" + filename + "\n" + "Size: " + parseInt((args.get_length()) / 1048576) + " MB" + " (" + args.get_length()+") bytes";
document.getElementById('<%=lblStatus.ClientID%>').innerText = text;
}
}
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="Server">
<h1>Add Movies to storage</h1>
<p>File upload<p>
<br />
<asp:AsyncFileUpload ID="AsyncFileUpload1" Width="400px" runat="server" OnClientUploadError="uploadError"
OnClientUploadStarted="StartUpload" OnClientUploadComplete="UploadComplete" CompleteBackColor="Lime"
UploaderStyle="Modern" ErrorBackColor="Red" ClientIDMode="AutoID" ThrobberID="Throbber"
UploadingBackColor="#66CCFF" OnUploadedComplete="AsyncFileUpload1_UploadedComplete" />
<asp:Label class="lastoppimg" ID="Throbber" runat="server" CssClass="style1">
<img src="../Movies/LoadingImg.gif" style="left:auto; right:auto; height:32px; width:32px;" alt="loading" />
</asp:Label>
<br />
<asp:Button class="lastoppk" ID="Button1" runat="server" Text="Start Upload" OnClick="Button3_Click" />
<asp:Label ID="lblStatus" runat="server" Style="font-family: Arial; font-size: small;"></asp:Label>
</div>
</div>
Codebehind
protected void AsyncFileUpload1_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
{
if (AsyncFileUpload1.HasFile)
{
string strPath = MapPath("~/Test/") + Path.GetFileName(e.filename);
AsyncFileUpload1.SaveAs(strPath);
}
}
Miro is actually using FFMpeg for its transcoding.
You can use FFMpeg yourself or easier, You can use it from .NET by using the MediaHandlerPro component. (They also have a free version)