I have a page which uses cufon and asp:UpdatePanel. After ajax callback the new content does not replace tags with cufon. I've tried:
<script type="text/javascript">
alert('Cufon refresh start!');
Cufon.refresh();
alert('Cufon must be ok!');
</script>
But don't get any alert or cufon replacement.
Related to How to have a javascript callback executed after an update panel postback? I've used pageLoad event which is triggered after each postback:
<script type="text/javascript">
function pageLoad(sender, args) {
Cufon.refresh();
}
</script>
I use the following
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
function EndRequestHandler(sender, args) {
//rebind jquery here after update panel async postback!
InitSlider();
Cufon.refresh();
}
Related
I need help on freezing gridview column header in asp.net.
I have tried to create a css code on page source code as displayed below:
<style type="text/css">
.Freezing
{
position:relative ;
top:expression(this.offsetParent.scrollTop);
z-index: 10;
}
</style>
And after that i called the css into page load of web form.
GridView1.CssClass = "Freezing"
Nothing happens whenever i debug the web application with above codes.
Thanks in advance.
You may using third party for database. Below are the url
http://datatables.net/
you can use this jquery plugin https://github.com/laertejjunior/freezeheader/
in your asp.net page:
<script language="javascript" type="text/javascript">
$(document).ready(function () {
$("table").freezeHeader();
});
</script>
if your page work with ajax, add this script in the end of page, to the script continue working after postback
<script type="text/javascript" language="javascript">
var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_endRequest(EndRequestHandler);
function EndRequestHandler(sender, args) {
$("table").freezeHeader();
}
</script>
see demo in https://github.com/laertejjunior/freezeheader/
I hope this helps.
I use this jquery datepicker
I have input in the updatePanel
<input id="DateMask" type="text" />
and js code:
function SetD() {
alert(1);
}
$(document).ready(function () {
SetD();
$("#datepicker").datepicker({
changeMonth: true,
changeYear: true
});
});
But the problem is that when i post my form to the server i only refresh update panel so $(document).ready(function () doesn't work after refreshing ,so where i can execute my function from?
You need to rebind in the Sys.WebForms.PageRequestManager.add_endRequest event.
See this similar post jQuery $(document).ready and UpdatePanels?
To make it work you need to re-initialize it after the updates of UpdatePanel. You can do that by using the UpdatePanel functions. I also like here to note, that you also need to unbind it just before the UpdatePanel updates to avoid memory leaks.
<script type="text/javascript">
// if you use jQuery, you can load them when dom is read.
$(document).ready(function () {
var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_initializeRequest(InitializeRequest);
prm.add_endRequest(EndRequest);
// Place here the first init of the DatePicker
InitDatePicker();
});
function InitializeRequest(sender, args) {
// make unbind to avoid memory leaks.
$("#datepicker").unbind();
}
function EndRequest(sender, args) {
// after update occur on UpdatePanel re-init the DatePicker
InitDatePicker();
}
function InitDatePicker()
{
$("#datepicker").datepicker({
changeMonth: true,
changeYear: true
});
}
</script>
Almost the same question but on GridView: Asp.Net UpdatePanel in Gridview Jquery DatePicker
Using ASP.NET 4.0 (c#), I want to call a button's OnClientClick event from code-behind (server-side). How do I code that in the code-behind file so that when the page is rendered again, the OnClientClick event is fired like the user clicked the button?
Here are two ways to "call" the javascript alert function from code behind. You may be able to replace the alert function with your function:
public static void ShowAlert(Page page, String message)
{
String Output;
Output = String.Format("alert('{0}');",message);
page.ClientScript.RegisterStartupScript(page.GetType(), "Key", Output, true);
}
public static void ShowAlert(HttpResponse response, String message)
{
String Output;
Output = String.Format("<Script Language='javascript'> alert('{0}');</script>", message);
response.Write(Output);
}
Add a little JQuery to the page...
<head>
<!-- Add the jquery library to your page -->
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<!-- Document.ready runs when the page is loaded -->
<script type="text/javascript">
$(document).ready(function () {
$('#MyButtonID').click(); // Find the button and click it.
});
</script>
</head>
i have used JQuery date picker in form- form contains just one text box and when we clicks on it--> it pops up the JQUERY datepicker.
In other web form in same project --> i have used script manager, Update panel and one textbox --> when click on it - am not getting JQUERY Datepicker Popped.??
What will be the issue.?? Any problem with-> async. postback triggers..?/
Will there be any issues when JQUERY Datepicker used with AJAX controls..??
Do you initialize the datepicker correctly on PanelUpdate ?
<script type="text/javascript">
$(document).ready(function() {
$(".clDate").datepicker();
});
</script>
Also for the update panel to fix again the DatePicker after the ajax update you need the foloowing code
<script type="text/javascript">
var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_initializeRequest(InitializeRequest);
prm.add_endRequest(EndRequest);
function InitializeRequest(sender, args) {
}
function EndRequest(sender, args) {
$(".clDate").datepicker();
}
</script>
Update:About the Sys. -> http://msdn.microsoft.com/en-us/library/bb311028.aspx
I have an asp.net page with a save button within an updatepanel and contenttemplate. The save works nicely, but I am trying to add a "wait" gif while the save is happening using JQuery, but the ajaxStart event is not firing. I put a simple catch shown below:
$(document).ajaxStart(function () {
alert('starting');
}).ajaxStop(function () {
alert('done');
});
No alerts show when I click the save. Is there a problem when trying to capture ASP.net Ajax events, is asp doing some funky type of Ajax calls that can't be captured by Jquery?
Thanks, let me know if you have any ideas about this,
Mark.
The ASP.NET update panels seem to do their own thing... Tap into the PageReuqestManager and setup your own calls here...
EDIT
I simplified the functions a bit below to match your sample a little more...
<script type="text/javascript">
function pageLoad() {
if (!Sys.WebForms.PageRequestManager.getInstance().get_isInAsyncPostBack()) {
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(AjaxEnd);
Sys.WebForms.PageRequestManager.getInstance().add_initializeRequest(AjaxBegin);
}
}
function AjaxEnd(sender, args) {
alert("I am done...");
}
function AjaxBegin(sender, args) {
alert("I am about to start...");
}
</script>