Prevent LinqDataSource Where Clause From Resetting On Postback
Jan 13, 2010
I'm trying to set the where clause on a LinqDataSource object bound to a GridView programmatically on a button click, but when the GridView rebinds data (for instance, when the user sorts) the Where clause resets back to the empty string. Is there a way to prevent this, or is there a better way to filter my results?
Here is a button inside a listview that is using the LinqDataSource and also has a pager:
And here is the Code Behind that is triggered by the linkbutton:
It almost works. When i click it it loads and shows the current page of objects that have dates that are higher then todays date. Which is what i want. But as soon as you use the pager to go back or forward it reverts to the default, which is ALL articles, sorted by ID. How can i make the "where" selection stick through the paging?
I have a web site that works fine on the server. I purchased a new domain and set that up on my web server and set the home directory on to the server to the same location as the site that works.
However, my forms authentication ticket is being recreated on every page post back. Is there some setting in IIS that I'm missing under the new domain(IP)? If I access the site under one domain the ticket is saved and tracked fine. When I access it from the second domain (same home directory as first domain) the ticket is lost on postback.
Probably a simple fix to this I am not sure. Basically, I have a MasterPage that contains a Dropdownlist. This DDL controls what is displayed in ContentPlaceHolder. However, when postbacks are caused within the Contact Pages the DDL is resetting itself. How can I keep the selected value for the DDL between postbacks?
I have an updatepanel with a button inside. When I click the button the gridview inside the updatepanel is getting re-bound to its datasource. But if I scroll the page during this update the scrollbar bounces back to the position it had when I clicked the button (it happens when the update is complete). Can I prevent this in any way? I would like to scroll the page during this update wihout having the page bounce back to the "button click position" when done updating.
When an asynchronous postback happened inside update panel, another postback happens also for MasterPagenot only update panel embedded page .I want to prevent this MasterPage postback . is this possible ?think like i have a MasterPage and another page which is test.aspx which is content page of MasterPagei have update panel at test.aspxwhen asynchronous postback happens at this test.aspx update panel it also loads MasterPage Page_Loadi want to prevent this (it should not also load MasterPage Page_Load)
Simple one here... is there a clean way of preventing a user from double-clicking a button in a web form and thus causing duplicate events to fire?
If I had a comment form for example and the user types in "this is my comment" and clicks submit, the comment is shown below... however if they double-click, triple-click or just go nuts on the keyboard they can cause multiple versions to be posted.
Client-side I could quite easily disable the button onclick - but I prefer server-side solutions to things like this
Is there a postback timeout per viewstate that can be set for example?
I have a web page (aspx) which takes longer time to load the page. If this page is loading and if user requests same page by clicking menu link again, it is considered as not postback and page starts loading again (as soon as it finished first page load).
I want to prevent this from happening. When page is loading and user requests same page again, it should not process those requests and should be neglected.
This aspx page is requested from menu (which is designed on seperate master page).
I'm using the ModalPopupExtender control from the AJAX toolkit. This control extends a panel which contains a CreateUserWizard control. However, the validation of the CreateUserWizard control causes a postback to the server, which closes the popup. I'd like the popup to remain open, even after the postback.
I have a treeview loaded with nodes. When I click on a node that is set to .Selected, I want a frame to load with that node's objects. Instead, it appears that the TreeView is posting back and causing the node that was clicked to be lost. For example,setting the below function to OnSelectedNodeChanged causes a NullReferenceException.
Protected Function LoadObject(ByVal sender As Object, ByVal e As EventArgs) Dim node As TreeNode = tv1.SelectedNode Response.Write(node.Text.ToString())
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.
This code opens me a dialog box with Ok and Cancel button but it do not wait for user activity and post the page immediately and the label gets populated. I need to call the c# function based on user activity. If user clicks "Ok" label should get populated and if user clicks "Cancel" it should not call the c# function. How do I achieve this?
I am developing an application that manages a photo contest. In that application, I use an AsyncFileUpload control for the user selected photo. The server-side UploadedComplete does basic validation, and scales/clip the image as necessary.
The problem is, when i click on the submit button on the page, the content of the AsyncFileUpload gets sent with the other user-submitted data, so the user gets to wait twice as long to get a response from the server (I'm expecting photos that are between 3 and 7 Mb big, which takes a minute or two to upload).
My form looks like that:
<%-- ... snip - all other fields ... --> <div style="margin-top: 20px; margin-bottom: 5px;"> <span class="texteB"><b>Upload a photo</b></span><br /> Browse your computer to find a photo.</div> <div>
Is there something I missed out in the documentation? I've been working on this all day without much success.
I am checking to see on the form if they answer No to question one then go to comments. On the client side I added autopostback="true". So when the page reloads the random number in the label is updating to a new number. How can I avoid the random number not to be updated when the page post pack to itself?
Protected Sub form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles form1.Load Dtetxt.Text = Date.Now F() End Sub Private Sub F() Dim _r As New Random() Dim n As Integer = _r.[Next](5) ' Can return 0, 1, 2, 3, or 4 Label2.Text = n.ToString End Sub