Below is my design and code where I am trying to redirect to previous page on button click which doesnt work.
<asp:ImageButton ID="btn_back" runat="server" ImageUrl="~/go_back.jpg" OnClientClick="Back()" Height="41px" Width="49px" />
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<link rel='stylesheet' href='style_demo.css' type='text/css' media='all' />
<style type="text/css">
.auto-style5 {
height: 33px;
}
</style>
<script type="text/javascript">
function Back() {
debugger;
history.go(-2);
return false;
}
</script>
</head>
<body>
Use the following:
history.back();
If your desired page is always your last page you navigate from, you can go back.
window.history.back();
Related
I have copied this code from a website http://www.aspdotnet-suresh.com/2012/04/jquery-dropdownlist-selection-for.html and its not showing me the desired output, I'm Naive at this but the calendar is not visible below the textbox which should as per the code.
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8"/>
<title>jQuery UI Datepicker - Default functionality</title>
<link type="text/css" href="css/ui-lightness/jquery-ui-1.8.19.custom.css" rel="stylesheet" />
<script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.19.custom.min.js"></script>
<script type="text/javascript">
$(function () {
$("#txtDate").datepicker({
changeMonth: true,
changeYear: true,
yearRange: '1970:2012'
});
});
</script>
<style type="text/css">
.ui-datepicker { font-size:8pt !important}
</style>
</head>
<body>
<form id="form1" runat="server">
<div class="demo">
<b>Date:</b> <asp:TextBox ID="txtDate" runat="server"/>
</div>
</form>
</body>
</html>
You can also set up calendar by using ajax calendar extender..
<asp:CalendarExtender ID="txtDate_CalendarExtender" runat="server"
Enabled="True" TargetControlID="txtDate" Format="dd/MMM/yyyy">
</asp:CalendarExtender>
As per you First statement you copied the code so check that your application contain js folder or not
Make sure that your website project includes the reference files in your project
css/ui-lightness/jquery-ui-1.8.19.custom.css
js/jquery-1.7.2.min.js
js/jquery-ui-1.8.19.custom.min.js
If not you can download the same from jquery site and include same in your project or provide http path for reference files
I am trying to use a javascript method in a content page (Referencing master page) to get the current screen dimensions, and write it to a label.
So far, I have had no luck. I tried doing it in both the master, and content page, but the method is simply not working.
Could someone please provide the solution for this?
MasterPage:
<head runat="server">
<title>Lake, Smit People</title>
<!--[if IE ]>
<link rel="stylesheet" type="text/css" href="ProfileStypeSheetIE.css" />
<![endif]-->
<!--[if !IE]>-->
<link href="ProfileStypeSheet.css" rel="stylesheet" type="text/css" />
<!--<![endif]-->
<asp:ContentPlaceHolder id="head" runat="server">
</asp:ContentPlaceHolder>
<style type="text/css">
.style1 { width: 378px; }
</style>
</head>
Default.aspx
<asp:Content ID="Content5" ContentPlaceHolderID="head" Runat="Server">
<script type="text/javascript">
var height = screen.height;
document.getElementById('<%= hiddenLabel.ClientID%>').value = height;
</script>
</asp:Content>
Hello you can try with theses lines, you specific case is the third (clientHeight and clientWidth)
document.body.scrollWidth, document.body.scrollHeight // for the full size of the document
document.body.offsetWidth, document.body.offsetHeight //to the displayed size
document.body.clientWidth, document.body.clientHeight //customer for size displayed
Have you tried following?
<a href="javascript:alert
('Your resolution is ' + screen.width + 'x' + screen.height);">
Click for your screen resolution </a>
I have the following mark-up:
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="jqueryFancyBox.WebForm1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<link href="jquery.fancybox-1.3.4.css" rel="stylesheet" type="text/css" />
<script src="http://code.jquery.com/jquery-1.6.4.js" type="text/javascript"></script>
<script src="jquery.fancybox-1.3.4.pack.js" type="text/javascript"></script>
<title></title>
</head>
<script type="text/javascript">
$(document).ready(function () {
$.fancybox({
'showCloseButton': true,
'hideOnContentClick': true,
'href': '#popUpAnnouncement',
'centerOnScroll': true
});
});
</script>
<body>
<form id="form1" runat="server">
<div>
<div style="display: none" id="popUpAnnouncement">
close
lalalalala
</div>
<input type="button" id="btn" value="lala" />
</div>
</form>
</body>
</html>
The modal pops up at pageload but after it closes the div is still shown at the top of the page. How do I hide the div, after it's been closed.
Thanks in advance!
Not sure if it has to do with your problem, probably not. But make sure you place the script tag inside head or body, not between them.
You can use the onClosed option:
...
<script type="text/javascript">
$(document).ready(function () {
$.fancybox({
'showCloseButton': true,
'hideOnContentClick': true,
'href': '#popUpAnnouncement',
'centerOnScroll': true,
'onClosed': function(){$('#popUpAnnouncement').hide();}
});
});
</script>
</head>
<body>
....
I am stuck with this error and found a work around and the solutions works for me, but i i would like to know is it the best way to fix the issue and i want to make sure that it wont affect any other pages badly. Hope the experts will help.
If this was the best solution then many of you can save your heads.
This error occurs when a code block is placed in the MasterPage. Place the code block in a placeholder to resolve the issue.When adding AJAX extenders to your Web page, it will attempt to register scripts in the head. If code blocks are present in the MasterPage, an error might occur.
To resolve this issue, simply move the code block into a placeholder in the head of your MasterPage, like so:
<head id="Head1" runat="server">
<title>Untitled Page</title>
<link href="StyleSheet.css" rel="stylesheet" type="text/css" />
<asp:ContentPlaceHolder ID="myPlaceholder" runat="server">
<script language="javascript" type="text/javascript" src="<%= Page.ResolveClientURL("~/javascript/global.js")%>"></script>
</asp:ContentPlaceHolder>
<asp:ContentPlaceHolder ID="head" runat="server"></asp:ContentPlaceHolder>
</head>
The error is logical you can not confuse the rendered controls after they rendered by using the <%= %>
One way to solve this issue is to use a literal control, and render the script line on code behind.
<asp:ContentPlaceHolder ID="myPlaceholder" runat="server">
<asp:Literal runat="server" ID="txtIncludeScript" EnableViewState="false"></asp:Literal>
</asp:ContentPlaceHolder>
and on code behind. Check for null because if you change the placeholder the literal is null. Also set EnableViewState=false because you set it on every Page_Load and you do not wish to save it to viewstate.
if(txtIncludeScript != null)
{
txtIncludeScript.Text =
string.Format("<script language=\"javascript\" type=\"text/javascript\" src=\"{0}\"></script>",
Page.ResolveClientUrl("~/javascript/global.js"));
}
ContentPlaceHolder requires a master page, so you can replace that tag with some other element that can be ran at the server in case your page does not have a master page and you cannot get rid of the
<head id="Head1" runat="server">
<title>Untitled Page</title>
<link href="StyleSheet.css" rel="stylesheet" type="text/css" />
<div runat="server">
<script language="javascript" type="text/javascript" src="<%= Page.ResolveClientURL("~/javascript/global.js")%>"></script>
</div>
<asp:ContentPlaceHolder ID="head" runat="server"></asp:ContentPlaceHolder>
</head>
While I'm using Response.Redirect("~/Pages/Page.aspx"), style is loaded on the page, but unfortunately it is not loaded while I'm using Server.Transfer("~/Pages/Page.aspx") method.
The page looks following:
<html>
<head runat="server">
<link href="../Css/Layout/style.css" type="text/css" rel="stylesheet" />
</head>
<body></body>
</html>
How to make the page load style.css using Server.Transfer() ?
Regards
The problem is that you use a relative path to your CSS file, you should use an abolute path.
If the css folder is inside your application root, you can use
<html>
<head runat="server">
<link href="/Css/Layout/style.css" type="text/css" rel="stylesheet" />
</head>
<body></body>
</html>
or even
<html>
<head runat="server">
<link href="~/Css/Layout/style.css" type="text/css" rel="stylesheet" runat="server" ID="aUniqueId" />
</head>
<body></body>
</html>