Hi.... I am getting a problem in javascript in aspx page... i have included an onclick event in a asp button like this.... aspx page whole code:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="UserUploads.aspx.cs" Inherits="QlixooWeb.UserUploads" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Register Assembly="FlashUpload" Namespace="FlashUpload" TagPrefix="FlashUpload" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Qlixoo::Uploads</title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<script src="js/jquery-latest.js" type="text/javascript"></script>
<script src="https://maps.googleapis.com/maps/api/js?sensor=false&libraries=places"
type="text/javascript"></script>
<style type="text/css">
span
{
cursor: pointer;
}
.uploads
{
width: 625px;
height: 335px;
border: 1px solid #353535;
border-radius: 7px;
background-color: #363636;
display: none;
}
</style>
<script type="text/javascript">
function confirmUpload()
{
alert("Uploaded Successfully");
window.location.href = "UserUploads.aspx?Tag=1";
}
function ShowVideoUpload()
{
$(document).ready(function(){
$("#div_VideoUpload").show();
$("#div_FlashUpload").hide();
});
}
function ShowFlashUpload()
{
$(document).ready(function(){
$("#div_FlashUpload").show();
$("#div_VideoUpload").hide();
});
}
function initialize()
{
var txtM = document.getElementById("hdn_Tagging").value;
txtM = txtM.slice(0, -1);
var arrTxtM = txtM.split(",");
var mapOptions = {
center: new google.maps.LatLng(-33.8688, 151.2195),
zoom: 13,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById('map_canvas'),
mapOptions);
var input, autocomplete;
for(var i=0;i<arrTxtM.length;i++)
{
input = document.getElementById(arrTxtM[i]);
autocomplete = new google.maps.places.Autocomplete(input);
}
var marker = new google.maps.Marker({
map: map
});
google.maps.event.addListener(autocomplete, 'place_changed', function () {});
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<form id="form1" runat="server">
<center>
<script type="text/javascript">
function DoneClick() {
alert("OO");
var checkLocation = "";
var txtMM = document.getElementById("hdn_Tagging").value;
txtMM = txtMM.slice(0, - 1);
var arrTxtMM = txtMM.split(",");
for (var j = 0; j < arrTxtMM.length; j++) {
var Loc = document.getElementById(arrTxtMM[j]).value;
if (Loc == "") {
checkLocation = "";
break;
} else {
checkLocation += Loc + ":";
}
}
if (checkLocation != "") {
var url = 'Handler/newExifDetails.ashx?Id=' + txtMM + '&Location=' + checkLocation + '';
alert(url);
alert("yes");
$.getJSON(url, function (json) {
alert(json);
console.dir(json);
$.each(json, function (i, weed) {
alert("good");
var res = weed.res;
alert(res);
if (res == null) {
} else {
window.top.location.href = "Dashboard.aspx";
}
});
});
} else {
alert("Please pick the locations for all objects");
}
}
</script>
<div style="padding: -1px 35px 0px 0px">
<%----%>
<div style="width: 100%" class="titletext">
<span önclick="ShowFlashUpload()">Add Memories</span> / <span>
<%----%>
Video Memories</span> / Facebook Memories
</div>
<div id="div_FlashUpload" runat="server" style="width: 625px; height: 335px; border: 1px solid #353535;
border-radius: 7px; background-color: #363636">
<FlashUpload:FlashUpload ID="flashUpload" runat="server" FileTypeDescription="Images"
FileTypes="*.gif; *.png; *.jpg; *.jpeg; *.wmv;*.mp4;*.mpg;*.flv;*.mp3" önUploadComplete="confirmUpload();"
TotalUploadSizeLimit="999999999" UploadFileSizeLimit="999999999" UploadPage="Uploader.aspx" />
</div>
<div id="div_FlashReturn" runat="server" class="uploads">
<asp:DataList ID="dl_tagging" runat="server" RepeatDirection="Horizontal" RepeatColumns="2"
OnItemDataBound="dl_tagging_ItemDataBound">
<ItemTemplate>
<div style="width: 290px; margin: 7px;">
<img alt="alt" id="img_Tagging" runat="server" style="width: 100px; height: 100px;
padding-left: 80px" />
<input type="text" id='<%#Eval("UpListId") %>' style="width: 260px; margin-top: 9px" />
<%----%>
</div>
</ItemTemplate>
<FooterTemplate>
<asp:Label ID="lblEmpty" Text="Not any images for tagging!!" Style="color: Red; width: 140px"
runat="server" Visible='<%#bool.Parse((dl_tagging.Items.Count==0).ToString())%>'>
</asp:Label>
</FooterTemplate>
</asp:DataList>
<div style="margin: 12px 12px 12px 40px;">
<asp:Button ID="btn_Tagging" CssClass="button" UseSubmitBehavior="false" Text="Done"
runat="server" OnClientClick="DoneClick()"/><%----%>
<%----%>
<div id="map_canvas" style="display: none">
</div>
<asp:HiddenField ID="hdn_Tagging" runat="server" />
</div>
<div id="div_VideoUpload" runat="server" class="uploads">
<div style="float: left; padding-removed 4px" class="subheading">
Please do not close this window while uploading,before getting 'Save Video' Option</div>
<iframe id="iframeVideoupload" runat="server" target="_Parent" frameborder="0" width="100%"
scrolling="no" height="300px" src="">
</iframe>
</div>
<div id="div_VideoReturn" runat="server" class="uploads">
<asp:Button ID="btnsave" runat="server" CssClass="button" OnClick="btnVideosave_Click"
Text="Save" />
<asp:Label ID="lbl_msg" runat="server" CssClass="error"></asp:Label>
</div>
</div>
</div>
</center>
</form>
</body>
</html>
Code behind of this is:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using ClassLib_MDL;
using ClassLib_BLL;
namespace QlixooWeb
{
public partial class UserUploads : System.Web.UI.Page
{
public static readonly UserUploadsMDL oUserUploadsMdl = new UserUploadsMDL();
public static readonly UserUploadsBLL oUserUploadsBll = new UserUploadsBLL();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Session["UserId"] == null)
Page.RegisterStartupScript("RedirectScript1", "<script type=text/javascript>window.parent.location = 'Login.aspx'</script>");
else if (Session["UserId"].ToString() == "0")
Page.RegisterStartupScript("RedirectScript2", "<script type=text/javascript>window.parent.location = 'Login.aspx'</script>");
else
{
oUserUploadsMdl.UserId = Convert.ToString(Session["UserId"]);
string test = Convert.ToString(Session["Tagging"]);
if (Request.QueryString["Tag"] != null)
{
Session["Tagging"] = "0";
GetTagImages(Convert.ToString(Session["UserId"]));
}
else
{
if (Request.QueryString.HasKeys())
{
if (Request.QueryString["ThumbUrl"] != null)
if (Request.QueryString["VideoUrl"] != null)
{
oUserUploadsMdl.Latitude = 0;
oUserUploadsMdl.Longitude = 0;
oUserUploadsMdl.GpsDate = "0";
div_VideoReturn.Style.Value = "display:";
div_VideoUpload.Style.Value = "display:none";
}
}
flashUpload.QueryParameters = string.Format("User={0}", Session["UserId"].ToString());
}
}
}
}
private void GetTagImages(string userId)
{
try
{
var ds = (DataSet)oUserUploadsBll.GetTagImages(userId);
if (ds != null && ds.Tables[0].Rows.Count != 0)
{
hdn_Tagging.Value = "";
Cache["ods"] = ds;
dl_tagging.DataSource = ds;
dl_tagging.DataBind();
div_FlashUpload.Style.Value = "display:none;";
div_FlashReturn.Style.Value = "display:block;overflow:scroll";
}
}
catch (Exception)
{
throw;
}
}
protected void dl_tagging_ItemDataBound(object sender, DataListItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
int userId = Convert.ToInt32(Session["UserId"]);
int index = e.Item.ItemIndex;
var ds = (DataSet)Cache["ods"];
var img_Tagging = (HtmlImage)e.Item.FindControl("img_Tagging");
img_Tagging.Src = "storage/" + userId + "/" + ds.Tables[0].Rows[index]["UpFileName"].ToString();
hdn_Tagging.Value += ds.Tables[0].Rows[index]["UpListId"].ToString() + ",";
}
}
protected void btnVideosave_Click(object sender, EventArgs e)
{
try
{
int res = oUserUploadsBll.SaveVideo(oUserUploadsMdl);
if (res > 0)
{
Page.RegisterStartupScript("Success", "<script type=text/javascript>alert('Video Uploaded Successfully');</script>");
div_VideoReturn.Style.Value = "display:none";
div_VideoUpload.Style.Value = "display:";
}
else
lbl_msg.Text = "Error occured,please upload again";
}
catch (Exception)
{
throw;
}
}
}
}
But this js works only if i put a breakpoint in the firebug for this function or in chrome check scripts there also if i put breakpoint alert is showing and it works but... if i just try and click the button it does not show the alert and page redirect is also not happening.... So can u please help me solve this error as i am unable to find any solution for this... Thanking You in advance!!