Search Results

Search found 729 results on 30 pages for 'postback'.

Page 4/30 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • How do I register a Javascript function to run with every postback?

    - by Kevin
    I have a treeview in a user control. I need to run a javascript function with every synch postback to scroll the div it's in to the right position. I've got it working, but I think there has to be a "cleaner" way to do it. In the Page_Load function of the control, I have the following code. Is there a better way to do it? ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "key" + DateTime.Now.Ticks, "RestorePosition();", true);

    Read the article

  • How can I get a custom made set of checkboxes return values in the postback?

    - by AngryHacker
    I have the following in an aspx page: <td colspan="2"> <% DisplayParties(); %> </td> In the code behind for the aspx page, i have this (e.g. I build HTML for the checkboxes): public void DisplayParties() { var s = new StringBuilder(); s.Append("<input type=\"checkbox\" id=\"attorney\" value=\"12345\"/>"); s.Append("<input type=\"checkbox\" id=\"attorney\" value=\"67890\"/>"); s.Append("<input type=\"checkbox\" id=\"adjuster\" value=\"125\"/>"); Response.WriteLine(s.ToString()); } Not my proudest moment, but whatever. The problem is that when this page posts back via some event on the page, I never get these tags in the Request.Form collection. Is this simply how ASP.NET works (e.g. only server-side control post back) or am I missing something simple. My understanding was that a postback should bring back all the form variables.

    Read the article

  • Wiring up JavaScript handlers after a Partial Postback in ASP.NET

    - by Richard
    I am trying to use LinkButtons with the DefaultButton property of the ASP.NET Panel in an UpdatePanel. I have read and used the various other answers that are around describing the wiring up of the click event so that a full postback is not done instead of a partial postback. When the page loads, I wire up the .click function of the LinkButton so that the DefaultButton property of the ASP.NET panel will work. This all works fine, until you bring an UpdatePanel into the mix. With an UpdatePanel, if there is a partial postback, the script to wire up the .click function is not called in the partial postback, and hitting enter reverts to causing a full submit of the form rather than triggering the LinkButton. How can I cause javascript to be executed after a partial postback to re-wire up the .click function of the LinkButton? I have produced a sample page which shows the problem. There are two alerts showing 1) When the code to hook up the .click function is being called, and 2) When the .click function has been called (this only happens when you hit enter in the textbox after the event has been wired up). To test this code, type something in the textbox and hit Enter. The text will be copied to the label control, but "Wiring up Event Click" alert will not be shown. Add another letter, hit enter again, and you'll get a full postback without the text being copied to the label control (as the LinkButton wasn't called). Because that was a full postback, the Wiring Up Event Click event will be called again, and the form will work properly the next time again. This is being done with ASP.NET 3.5. Test Case Code: <%@ Page Language="C#" Inherits="System.Web.UI.Page" Theme="" EnableTheming="false" AutoEventWireup="true" %> <script runat="server"> void cmdComplete_Click(object sender, EventArgs e) { lblOutput.Text = "Complete Pressed: " + txtInput.Text; } void cmdFirstButton_Click(object sender, EventArgs e) { lblOutput.Text = "First Button Pressed"; } protected override void OnLoad(EventArgs e) { HookupButton(cmdComplete); } void HookupButton(LinkButton button) { // Use the click event of the LinkButton to trigger the postback (this is used by the .click code below) button.OnClientClick = Page.ClientScript.GetPostBackEventReference(button, String.Empty); // Wire up the .click event of the button to call the onclick function, and prevent a form submit string clickString = string.Format(@" alert('Wiring up click event'); document.getElementById('{0}').click = function() {{ alert('Default button pressed'); document.getElementById('{0}').onclick(); }};", button.ClientID, Page.ClientScript.GetPostBackEventReference(button, "")); Page.ClientScript.RegisterStartupScript(button.GetType(), "click_hookup_" + button.ClientID, clickString, true); } </script> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>DefaultButton/LinkButton Testing</title> <style type="text/css"> a.Button { line-height: 2em; padding: 5px; border: solid 1px #CCC; background-color: #EEE; } </style> </head> <body> <h1> DefaultButton/LinkButton Testing</h1> <form runat="server"> <asp:ScriptManager runat="server" /> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <div style="position: relative"> <fieldset> <legend>Output</legend> <asp:Label runat="server" ID="lblOutput" /> </fieldset> <asp:Button runat="server" Text="First Button" ID="cmdFirstButton" OnClick="cmdFirstButton_Click" UseSubmitBehavior="false" /> <asp:Panel ID="Panel1" runat="server" DefaultButton="cmdComplete"> <label> Enter Text:</label> <asp:TextBox runat="server" ID="txtInput" /> <asp:LinkButton runat="server" CssClass="Button" ID="cmdComplete" OnClick="cmdComplete_Click" Text="Complete" /> </asp:Panel> </div> </ContentTemplate> </asp:UpdatePanel> <asp:Button runat="server" ID="cmdFullPostback" Text="Full Postback" /> </form> </body> </html>

    Read the article

  • TemplateField button causing GridView Invalid Postback

    - by Carter
    Ok, so I've got a template field in a gridview that contains just a simple button... <asp:GridView ID="KeywordsGridView" AllowPaging="false" AutoGenerateColumns="false" BackColor="white" GridLines="None" HeaderStyle-CssClass="Table_Header" RowStyle-CssClass="Table_Style" runat="server"> <Columns> <asp:TemplateField> <ItemTemplate> <asp:Button runat="server" /> </ItemTemplate> </asp:TemplateField> <asp:BoundField DataField="References" SortExpression="References" HeaderText="Total References" /> <asp:BoundField DataField="Keyword" SortExpression="Keyword" HeaderText="Keyword" /> </Columns> </asp:GridView> Whenever I click the button I get the error... Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation. I've found a decent amount of articles referencing this issue, including a couple on SO, for example... http://stackoverflow.com/questions/228969/asp-net-invalid-postback-or-callback-argument-event-validation-is-enabled-usi and... http://stackoverflow.com/questions/103560/invalid-postback-or-callback-argument I might just be misunderstanding, but as far as I can tell they don't really help me. How do I get this to go away without setting enableEventValidation="false"?

    Read the article

  • Can I create an ASP.NET ImageButton that doesn't postback?

    - by Giffyguy
    I'm trying to use the ImageButton control for client-side script execution only. I can specify the client-side script to execute using the OnClientClick property, but how do I stop it from trying to post every time the user clicks it? There is no reason to post when this button is clicked. I've set CausesValidation to False, but this doesn't stop it from posting.

    Read the article

  • How to Prevent PostBack Event Handler from Firing

    - by user331744
    I have a custom class (ServerSideValidator.vb) that validates user input on server side (it doesn't use any of the .NET built in validators, therefore Page.Validate() is not an option for me). I am calling the Validate() method on page.IsPostback event and the class performs without any problem My issue is, when validation fails (returns false), I want to stop the postback event handler from firing, but load the page along with all the controls and user-input values in them. If I do, Response.End(), the page comes up blank. I can programmatically instruct the page to go to the previous page (original form before postback), but it loses all user-inputs. I thought of creating a global boolean variable in the page code behind file and check the value before performing any postback method, but this approach takes away from my plan to provide all functionalities inside the class itself. The page object is being referenced to ServerSideValidator. Seems like all the postback related properties/variables I come across inside Page class are 'Readonly' and I can't assign value(s) to control/prevent postback event from firing. Any idiea on how I can accomplish this? Please let me know if you need further details

    Read the article

  • Saving Dragged Dropped items position on postback in asp.net [closed]

    - by Deeptechtons
    Ok i saw many post's on how to serialize the value of dragged items to get hash and they tell how to save them. Now the question is how do i persist the dragged items the next time when user log's in using the has value that i got eg: <ul class="list"> <li id="id_1"> <div class="item ui-corner-all ui-widget ui-widget-content"> </div> </li> <li id="id_2"> <div class="item ui-corner-all ui-widget ui-widget-content"> </div> </li> <li id="id_3"> <div class="item ui-corner-all ui-widget ui-widget-content"> </div> </li> <li id="id_4"> <div class="item ui-corner-all ui-widget"> </div> </li> </ul> which on serialize will give "id[]=1&id[]=2&id[]=3&id[]=4" Now think that i saved it to Sql server database in a single field called SortOrder. Now how do i get the items to these order again ? the code to make these sort is below,without which people didn't know which library i had used to sort and serialize <script type="text/javascript"> $(document).ready(function() { $(".list li").css("cursor", "move"); $(".list").sortable(); }); </script>

    Read the article

  • Event Handlers and Automatic Postback in ASP.NET 3.5 Web Controls

    In one of last week s tutorials Creating Database-Driven ASP.NET 3.5 Input and List Web Controls you learned how to create a dynamic input web control that instead of setting values statically stored its list and values directly from the MS SQL server 2 8 database. This tutorial is a sequel to that article. It deals mostly with the server side coding aspect of dynamic web controls. It is recommended that you read the earlier tutorial first as the Visual Web Developer Project in that tutorial will be used extensively in this article.... Download a Free Trial of Windows 7 Reduce Management Costs and Improve Productivity with Windows 7

    Read the article

  • ASP.NET GridView and UpdatePanel

    - by Echilon
    I have a GridView, inside a UserControl, inside an UpdatePanel on a page. There's a button in the GridView which needs to fire a postback. What happens is: User clicks button - RowCommand Fires - Custom event is raised on UserControl - Page detects this and changes the active view index for a multiview and also the page title and some other controls outside the UpdatePanel. The problem is, the page posts back asyncchronously, the page title changes, but the actions requireing a full postback don't happen because a full postback doesn't occur. To register the button as a postback trigger I'm using: ImageButton btnResults = e.Row.FindControl("btnResults") as ImageButton; ScriptManager scrCurrent = ScriptManager.GetCurrent(this.Page); if (btnResults != null && scrCurrent != null) { scrCurrent.RegisterPostBackControl(btnResults); } I know this is a bit of a complicated problem, but I'd really appreciate any help.

    Read the article

  • Why my events aren't registered after postback?

    - by lucian.jp
    I have a problem where I have a page with a checkbox : <asp:CheckBox runat="server" ID="chkSelectAll" OnCheckedChanged="chkSelectAll_CheckedChanged" EnableViewState="true" Text='<%# CommonFunctions.GetText(Page, "CreateTask", "chkSelectAll.text") %>' AutoPostBack="true" /> First I had the problem that when the event was raised the checkbox wasn't keeping the checked property value. This is still strange because nowhere in the application we set the EnableViewState to false and by default it should be true. Well this behavior was fixed by puting EnableViewState="true". So now, I have a checkbox that when I first load the page, wworks correctly. I check the box, the event is raised Checked property valu is good and the method is executed. Postback completes and renders the page. I check the box back to false, the event is not triggered and the page is reloaded with the previous data but the Checked Property stays at true. So after the first postback I seem to loose behavior of event and ViewState. We suspect the fact that we move dynamically the controls in the page (See answer here) But this suspicion doesn't explain why everything works perfectly after the first load and stops working after first PostBack. EDIT CODE SAMPLE I created a test project where you can experience my problem. At load if you check any checkbox both raise their respective event. After postback only the second raise both events. I seem to have a problem when I register the events after moving control.

    Read the article

  • MVC: On partial page start validation from JS without postback

    - by dwilliams459
    How do I start validation from the client/javascript using the MS MVC Validation library? Using MS ASP.Net MVC, I have a page with a PartialView in a modal dialog (change password). When the user selects 'save', I need to validate this on the client side without a full page postback. I am able in JS to post and refresh the partialView, however I am unable to start client validation. The MS MVC validation starts on postback (Input type='submit'). How can I start this in JS? Validation on the full page with postback works. Thanks, d

    Read the article

  • Dropdownlists creates postback on key changes in IE

    - by Dofs
    I have created a label and a dropdownlist. The label has the dropdownlist as associated id. If I click on the label and then uses the mouse up or down the dropdownlist creates a postback for each click. This is quite anoying and doesn't happen if you click on the dropdownlist and uses key-up or key-down, or if you uses another browser than IE. Is it possibel to fix this, so you can use key-up and key-down without causing a postback, and first on the enter-key creates the postback (as it does if you click on the dropdownlist and not label)?

    Read the article

  • ASP.NET Client to Server communication

    - by Nelson
    Can you help me make sense of all the different ways to communicate from browser to client in ASP.NET? I have made this a community wiki so feel free to edit my post to improve it. Specifically, I'm trying to understand in which scenario to use each one by listing how each works. I'm a little fuzzy on UpdatePanel vs CallBack (with ViewState): I know UpdatePanel always returns HTML while CallBack can return JSON. Any other major differences? ...and CallBack (without ViewState) vs WebMethod. CallBack goes through most of the Page lifecycle, WebMethod doesn't. Any other major differences? IHttpHandler Custom handler for anything (page, image, etc.) Only does what you tell it to do (light server processing) Page is an implementation of IHttpHandler If you don't need what Page provides, create a custom IHttpHandler If you are using Page but overriding Render() and not generating HTML, you probably can do it with a custom IHttpHandler (e.g. writing binary data such as images) By default can use the .axd or .ashx file extensions -- both are functionally similar .ashx doesn't have any built-in endpoints, so it's preferred by convention Regular PostBack (System.Web.UI.Page : IHttpHandler) Inherits Page Full PostBack, including ViewState and HTML control values (heavy traffic) Full Page lifecycle (heavy server processing) No JavaScript required Webpage flickers/scrolls since everything is reloaded in browser Returns full page HTML (heavy traffic) UpdatePanel (Control) Control inside Page Full PostBack, including ViewState and HTML control values (heavy traffic) Full Page lifecycle (heavy server processing) Controls outside the UpdatePanel do Render(NullTextWriter) Must use ScriptManager If no client-side JavaScript, it can fall back to regular PostBack with no JavaScript (?) No flicker/scroll since it's an async call, unless it falls back to regular postback. Can be used with master pages and user controls Has built-in support for progress bar Returns HTML for controls inside UpdatePanel (medium traffic) Client CallBack (Page, System.Web.UI.ICallbackEventHandler) Inherits Page Most of Page lifecycle (heavy server processing) Takes only data you specify (light traffic) and optionally ViewState (?) (medium traffic) Client must support JavaScript and use ScriptManager No flicker/scroll since it's an async call Can be used with master pages and user controls Returns only data you specify in format you specify (e.g. JSON, XML...) (?) (light traffic) WebMethod Class implements System.Web.Service.WebService HttpContext available through this.Context Takes only data you specify (light traffic) Server only runs the called method (light server processing) Client must support JavaScript No flicker/scroll since it's an async call Can be used with master pages and user controls Returns only data you specify, typically JSON (light traffic) Can create instance of server control to render HTML and sent back as string, but events, paging in GridView, etc. won't work PageMethods Essentially a WebMethod contained in the Page class, so most of WebMethod's bullet's apply Method must be public static, therefore no Page instance accessible HttpContext available through HttpContext.Current Accessed directly by URL Page.aspx/MethodName (e.g. with XMLHttpRequest directly or with library such as jQuery) Setting ScriptManager property EnablePageMethods="True" generates a JavaScript proxy for each WebMethod Cannot be used directly in user controls with master pages and user controls Any others?

    Read the article

  • UpdatePanel, JavaScript postback and changing querystring at same time in SharePoint Search Page

    - by Lee Dale
    Hi Guys, Been tearing my hear out with this one. Let me see if I can explain: I have a SharePoint results page on which I have a Search Results Core WebPart. Now I want to change the parameter in the querystring when I postback the page so that the WebPart returns different results for each parameter e.g. the querystring will be interactivemap.aspx?k=Country:Romania this will filter the results for Romania. First issue is I want to do this with javascript so I call: document.getElementById('aspnetForm').action = "interactivemap.aspx?k=Country:" + country; Nothing special here but the reason I need to call from Javascript is there is also a flash applet on this page from which the Javascript calls originate. When the javascript calls are made the page needs to PostBack but not reload the flash applet. I turned to ASP.Net AJAX for this so I wrapped the search results webpart in an update panel. Now if I use a button within the UpdatePanel to postback the UpdatePanel behaves as expected and does a partial render of the search results webpart not reloading the flash applet. Problem comes because I need postback the page from javscript. I called __doPostBack() as I have used this successully in the past. It works on it's own but fails when I first call the above Javascript before the __doPostBack() (I also tried calling click() on a hidden button) the code for the page is at the bottom. I think the problem comes with the scriptmanager not allowing a partial render when the form post action has changed. My questions are. A) Is there some other way to change the search results webpart parameter without using the querystring. or B) Is there a way around changing the querystring when doing an AJAX postback and getting a partial render. <asp:Content ContentPlaceHolderID="PlaceHolderFullContent" runat="server"> function update(country) { //__doPostBack('ContentUpdatePanel', ''); //document.getElementById('aspnetForm').action = "interactivemap.aspx?k=ArticleCountry:" + country; document.getElementById('ctl00_PlaceHolderFullContent_UpdateButton').click(); } Romania <div class="firstDataTitle"> <div class="datatabletitleOuterWrapper"> <div class="datatabletitle"> <span>Content</span></div> </div> <div class="datatableWrapper"> <div class="dataHolderWrapper"> <div class="datatable"> <div> <div class="searchMain"> <div class="searchZoneMain"> <asp:UpdatePanel runat="server" id="ContentUpdatePanel" UpdateMode="Conditional"> <ContentTemplate> <WebPartPages:webpartzone runat="server" AllowPersonalization="false" title="<%$Resources:sps,LayoutPageZone_BottomZone%>" id="BottomZone" orientation="Vertical" QuickAdd-GroupNames="Search" QuickAdd-ShowListsAndLibraries="false"><ZoneTemplate></ZoneTemplate></WebPartPages:webpartzone> <asp:Button id="UpdateButton" name="UpdateButton" runat="server" Text="Update"/> </ContentTemplate> </asp:UpdatePanel> </div> </div> </div> </div> </div> </div>

    Read the article

  • Scheduler with Asp Mvc

    - by Samuel
    Hi, I want to use a Scheduler like Telerik Scheduler in my Mvc project. The problem is that the Scheduler is a Asp.Net WebForm control. For this reason, I must create a WebForm page in my Mvc project to put the Scheduler control. When I show the page, it work fine to render the layout of the control but if I try to interact with it; click for change date, change to day view to week view, the control don't change. I know that postback doesn't work in mvc project but does it work in a WebForm page in a Mvc project? If it doesn't work, it is the reason why when I try to interact with the control, the control don't respond. I think it's because the postback don't work and the Scheduler use 100 % Databinding where when I change date, the postback don't contain any data that I have changed and for this reason, the control can't change is layout. Have you any ideas about postback with WebForm in mvc project? What type of design can I adopt? (Two differents projets: One for my Scheduler with WebForm and another for all the rest of my website in Mvc project) Any other control easily to use with Scheduler? Tips and tricks when needing both WebForm control and Mvc control in Mvc project? Thank you very much.

    Read the article

  • UpdatePanel on masterpage does postback on first button click

    - by gevjen
    I have an update panel on a masterpage and for reasons unbeknown to me our content placeholder is within the updatepanel. But when I click on a button on one of our pages that uses the masterpage the page postsback. If I then click the button for a second time it does not postback and does an ajax call. Im wondering why it does a postback the first time when I dont want it to. Below is how I have the updatepanel set up

    Read the article

  • How to set state of controls from viewstate on non PostBack page

    - by n1zero
    I am currently saving viewstate of pages in cache. I can see that viewstate is rebinding values and controls on PostBack. It is working properly on postback. However, I need to recreate state on a non-post back page.The key i'm using for loading viewstate from cache is being passed in the querystring but I am unable to find a way to force viewstate to load on a non-post back page. Is there any way to force a load of viewstate on a Non-Postbacked Page?

    Read the article

  • No postback on any button click on ASP.NET 4.0 application

    - by Ashish Gupta
    The weird thing is If there is a javascript onClick() on a button, postback works otherwise, there is no postback. This was working very recently. I am not sure what recent changes made to the application made this happening throughout the site. The solution suggested by this link does not work as well (that link is applicable to .NET 1.1 though). Any idea whats going on?

    Read the article

  • Javascript disabling my postback

    - by LoveMeSomeCode
    I have an ASP.NET checkbox, and I want to run some javascript before it posts back. Something like: <asp:CheckBox ID="chkSelected" runat="server" AutoPostBack="True" OnCheckedChanged="chkSelected_CheckedChanged" /> but I want to run a JS confirm dialog when the user click it, and if they were UNCHECKING it, I'd like to ask them if they're sure, and if so, postback and run my serverside code. If they say No, don't postback at all. Anyone know of an 'easy' way to do this?

    Read the article

  • Selecting the contents of an ASP.NET TextBox in an UpdatePanel after a partial page postback

    - by Scott Mitchell
    I am having problems selecting the text within a TextBox in an UpdatePanel. Consider a very simple page that contains a single UpdatePanel. Within that UpdatePanel there are two Web controls: A DropDownList with three statically-defined list items, whose AutoPostBack property is set to True, and A TextBox Web control The DropDownList has a server-side event handler for its SelectedIndexChanged event, and in that event handler there's two lines of code: TextBox1.Text = "Whatever"; ScriptManager.RegisterStartupScript(this, this.GetType(), "Select-" + TextBox1.ClientID, string.Format("document.getElementById('{0}').select();", TextBox1.ClientID), true); The idea is that whenever a user chooses and item from the DropDownList there is a partial page postback, at which point the TextBox's Text property is set and selected (via the injected JavaScript). Unfortunately, this doesn't work as-is. (I have also tried putting the script in the pageLoad function with no luck, as in: ScriptManager.RegisterStartupScript(..., "function pageLoad() { ... my script ... }");) What happens is the code runs, but something else on the page receives focus at the conclusion of the partial page postback, causing the TextBox's text to be unselected. I can "fix" this by using JavaScript's setTimeout to delay the execution of my JavaScript code. For instance, if I update the emitted JavaScript to the following: setTimeout("document.getElementById('{0}').select();", 111); It "works." I put works in quotes because it works for this simple page on my computer. In a more complex page on a slower computer with more markup getting passed between the client and server on the partial page postback, I have to up the timeout to over a second to get it to work. I would hope that there is a more foolproof way to achieve this. Rather than saying, "Delay for X milliseconds," it would be ideal to say, "Run this when you're not going to steal the focus." What's perplexing is that the .Focus() method works beautifully. That is, if I scrap my JavaScript and replace it with a call to TextBox1.Focus(); then the TextBox receives focus (although the text is not selected). I've examined the contents of MicrosoftAjaxWebForms.js and see that the focus is set after the registered scripts run, but I'm my JavaScript skills are not strong enough to decode what all is happening here and why the selected text is unselected between the time it is selected and the end of the partial page postback. I've also tried using Firebug's JavaScript debugger and see that when my script runs the TextBox's text is selected. As I continue to step through it the text remains selected, but then after stepping off the last line of script (apparently) it all of the sudden gets unselected. Any ideas? I am pulling my hair out. Thanks in advance...

    Read the article

  • Double postback problem

    - by Juan Manuel Formoso
    Hi, I have a ASP.NET 1.1 application, and I'm trying to find out why when I change a ComboBox which value is used to fill another one (parent-child relation), two postbacks are produced. I have checked and checked the code, and I can't find the cause. Here are both call stacks which end in a page_load First postback (generated by teh ComboBox's autopostback) Second postback (this is what I want to find why it's happening) Any suggestion? What can I check?

    Read the article

  • Hide jquery dialog on asp.net postback

    - by mellowyellow77
    I feel like this is a stupid questions, but I am finding it hard to get this answered. I only want to show the jquery dialog when the page first renders. After the page renders there are multiple operations that cause the page to postback, but the user doesn't navigate away from that page. How do I disallow the jquery dialog from showing on those postback events. Thanks in advance!

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >