.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

RegisterStartupScript and UpdatePanel - Execute JS Function after postback

Posted By:      Posted Date: October 07, 2010    Points: 0   Category :ASP.Net



Is there a way for me to call a js function that I have registered the first time after a post back of an update panel?


In the first initial request to the page I register a script block and it works fine.

BUt it doesnt not fire or execute when the updatepanel does a post back.


I did a simple test and just did and page.ClientScript.reg...('alert("test"))

the code works so dont worry about my example syntax. I t just does an alert. The alert is executed once when the page was first requested. but not after a post back.  any ideas?




View Complete Post

More Related Resource Links

Execute jquery function after updatepanel.update


I want to execute following function after I have called updatepanel.update:

Public Sub StartScroller()
        Me.Page.ClientScript.RegisterClientScriptBlock(Me.[GetType](), "startscroll", "$(document).ready(function () {$('.scrollable').scrollable();});", True)
    End Sub

It doesnt work. I also tried RegisterStartupScript. I would expect the scrollable() method to be executed. But it doesnt.

    <asp:UpdatePanel ID="upnlCompareLocations" runat="server">
<a class="prev browse left"></a>
<div class="scrollable">   
   <!-- root element for the items -->
   <div class="items">

        <asp:ListView ID="repLocationsToCompare" ItemPlaceholderID="itemsGoHere" DataSourceID="XMLDSCompare" GroupItemCount="4" runat="server">
                <asp:PlaceHolder runat="server" ID="itemsGoHere"></asp:PlaceHolder>
                    <%# XPath("title&

Run a javascript function after UpdatePanel.Update()


I thought that adding the javascript within the ContentTemplate would cause it to run every time the UpdatePanel was updated.  For example, I would assume that for the following:

<atlas:UpdatePanel ID="UpdatePanel1" runat="server" Mode="Conditional" >
        Hello from inside the update panel!!!!
        <asp:Button ID="foo" runat="server" OnClick="foo_Click" Text="Click me to postback!" />
        <script type="text/javascript">alert('Javascript, baby!');</script>

 would cause the function alert() to run every time the UpdatePanel returns from the button click.  This is not the case, however.

How do I do this?  My update panel contains a scrolling Div and I

UpdatePanel - UpdateProgress only displays on initial postback



I'm having a somewhat odd issue, I'll do my best to explain it.

In a nutshell I have an UpdatePanel with an UpdateProgress item, first postback checks for warnings, if there are any they will be be displayed to the user as a JavaScript 'confirm' box. If the user clicks OK the next postback occurs to commit the change.

The UpdateProgress loading notification appears on the first postback but not on the second, even though both of them function correctly.  The buttons that trigger both postbacks are async postback triggers in the update panel, and both are inside the ContentTemplate.

It's not a huge problem, but it causes some confusion, has anybody ever seen this issue before?


Execute a function for specific time (not at specific time)


I have a function that does large amount of processing.

I just want that if it executes in specific time (say 10 min) then it should return "execution successful".

But if now then i want to stop the execution of that function and return "unsuccessful" and rollback my transactions.

Returning and rollback is fine.

But i dont know how to stop the execution of a function at specific time.

I am using asp.net with C#.

Any ideas would be really appreciated.


Problem with UpdatePanel postback

Hello,I have a Modal Popup window, inside an Update Panel object, that has the following layout:A Title areaA Content area with a tabstrip of 5 tabsA footer area with two buttons (Save and Cancel) and an UpdateProgressIn 3 of the five tabs I have:an UpdatePanel (UpdateMode=Conditional) that wrapsA collection of LinkButtons objectA gridviewAnother Panel object to be showed as a Nested Modal PopupNO update ProgressBoth the link collection and the gridview Select event will open the nested Modal window that contains a custom Usercontrol that is used to add new or edit object of the related gridview like in the code sample below//click handler of the LinkButton protected void btnNewPhone_Click(object sender, EventArgs e) { //Setup properties of the UserControl code omitted // ... //Show the nested Popup this.mpePopupPhone.Show(); } //handler for the gridview selectedIndex event protected void gvPhones_SelectedIndexChanged(object sender, EventArgs e) { //Setup properties of the UserControl code omitted // ... //Show the nested Popup this.mpePopupPhone.Show(); } Please note that: I am using the ModalPopupExtender show/hide behaviors using only server-side code. Also, the ModalPopupExtender objects for nested modal windows does not have the OkControlID & CancelControlID set. As the content of nested modal window is only a single user contro

Is there a function in Jquery which run only one time no matter load page or PostBack

In asp.net, I can use Method A to run somethings A one time, and somethings A will nor run when page is postback but In JQuery, I hope to run something B one time when the page is loaded, but if I use Method B, the "Somethings B" always run even the page is pastBack, how can I do? Thanks! ------------------Method A------------protected void Page_Load(object sender, EventArgs e){    if (!IsPostBack)    {       //Do Somethings A    } }   ------------------Method B------------$(document).ready(function () {   //Do Somethings B})

execute a javascript function in code page

I use js function in source page and call that js function as below in Source page<a href="javascript:;" onclick="openwin('Sample.aspx?DID=<%#Eval("UID") %>', '', '700','300','yes'); return false ">I need to call this function from vb.net code page.....how to solve this ........???????????Give ur ideas...............

How to use Store Procedure to execute the Function Of COM DLL (the DLL is Coded By C#)

Hi All, I find a question. How to use Store Procedure to execute the function of Dll? I tried as the steps: 1. Code a dll 2. Register the dll by "regasm XXX.dll /codebase" 3. Use the dll in SP But when I do it in step 3, I face some error, which is "Invalid class string" and the error ID is "0x800401F3" Could you help me solve this problem? Thank you very much.

UpdatePanel postback and resulting ViewState

Hi everyone,I'm reading about the UpdatePanel and how it interacts with controls inside & outside of it.  My understanding is that the usual ASP.Net pipeline takes place when posting from within an UpdatePanel-- Page load etc all fire off as normal-- except when the prerendering stage is reached.  In that case the ScriptManager does a final check and only renders those controls within the UpdatePanel and skips the rest.  That's my understanding at least.Sounds good, but for argument's sake let's say I have a TextBox located outside an UpdatePanel.  If a postback occurs from within that panel, the TextBox's properties can still be set in the page load method, but those changes will not take effect. (normally; it is possible to postback the entire page from an UpdatePanel)Is that correct?  What happens to that TextBox's ViewState in this instance?  Is it updated based on what happened to it in the page load method or is that modification tossed out because it wasn't in the UpdatePanel?

textbox not writable after partial postback of updatepanel

hi, i got a strange problem. my project was ok before implimenting ajax. i have just implimented ajax in one page only with Tabcontainer and updatepanels only nothing else. almost all controls are devided into different Tabs with respective update panels. mostly it is working ok. but the problem is : 1.   in some controls i am not able to write anything even the control is "Enabled=True" and focus is on the same control after partial postback. 2.   and as soon as i press Tab control goes to Address bar. 3.   some time tab key is also not working.Why ? here some code :<td style="width: 57684px; text-align: left">                                                Inception Date (dd-mm-yyyy)</td>                                            <td style="width: 604px; text-align: left">              &n

Error For Execute User Define Function in remote host.

Hi there.I wanna to call a user defined function in stored proc.it's ok in local test but in the host it rises error: Cannot find either column "dbo" or the user-defined function or aggregate "dbo.MinCount", or the name is ambiguous.What should i do?

Margin on div removed after async postback with UpdatePanel

Hi I have a series of div's inside an update panel, these divs have a margin-bottom defined in css. In IE8, when I do a async postback these margins are all removed. All the other styles are fine. If I turn on compatibility mode this does not happen. In Google Chrome the margins are maintained correctly after the async postbacks. Any idea why this is happening? -- Christian 

How to execute javascript function from datagrid row

 Hi I need to execute  a javascript function when a row of a datagrid is clicked. I am not sure how to do this. I have tried adding a template column with a button <asp:TemplateColumn>  <ItemTemplate>    <asp:Button ID="myButton" Text="Insert collection" OnClientClick="putData();" runat="server" />  </ItemTemplate></asp:TemplateColumn> And then attaching the javascript to it: myButton.Attributes.Add("onclick", "putData()") But it produces an error. Sorry this is a basic question, but what am I doing wrong?

Button forces postback in updatepanel inside Popup

I have an update panel which is inside a Modal Popup Extender. When I click the Refresh Report button it always calls a postback. I need to stop it from posting back. Ideas?

avoiding postback using updatepanel


Hi All:
I have a tabe container enclosed in updatepanel. In one of tabs, I have added a gridview. When I click that tab, and then click a linkbutton "view products" gridview is shown but posback occurs even the whole tab container is enclosed in updatepanel. how to avoid postback on link click ( gridview load)

Updating an ASP.NET CheckBoxList inside an UpdatePanel from a Javascript function



I have a asp.net listbox server control that is connected to a jquery plugin that can handle a client side click event for each of the checkboxes it renders.

Whenever I click on a checkbox the click event gets triggered and I make a call to

__doPostBack("UpdatePanel1"""); so that i can update the updatepanel and rebind the checkboxlist inside it.

is it possible to do the rebind first, and then update the updatepanel? how do i do that? because now, the rebind happens on the second time i click on the checkbox.




    <script type="text/javascript">
        $(function () {

Full PostBack in IE and Partial PostBack in other browsers using an UpdatePanel


I have an UpdatePanel that works fine and always updates the content when the RadioButtonList selected index is changed. What I want to do, is trigger full page postback in IE, but allow the UpdatePanel to do partial page postback in all other browsers.

Here's my markup (I removed the internals of the UpdatePanel since they are not relavent):

<asp:UpdatePanel ID="uplPodcasts" ChildrenAsTriggers="false" UpdateMode="Conditional" runat="server">
                    <div id="plPodcastsControls">
                	    <span style="font-weight: bold; line-height: 26px;">Display Mode:  </span>
                        <asp:RadioButtonList ID="rblPodcastsDisplay" CssClass="rblPodcastsDisplay" 

                            <asp:ListItem Selected="true" Text="Table" Value="table" />
                            <asp:ListItem Text="Grid" Value="grid" />
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend