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?
THis works fine to build my custom ContractSummary field, but of course the Rate (which is a double?) and enddate (which is a datetime?) will be unformatted. I tried using "Rate.Value.ToString("#,##0.00")" but got the error message "Method 'System.String ToString(System.String)' has no supported translation to SQL".
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)
Ive had several problems creating controls from page load during post back. I thought I came up with a solution but it only works partially. In a nutshell here's what happens:
I have a button that fires a java script function. The function performs a postback. page_load determines what control caused the postback by looking at Request["__EVENTARGUMENT"] If the EVENTARGUMENT starts with something specific, it calls the CreateDropDowns method CreateDropDownMethod creates a bunch of new dropdownlist In another method that is fired from a seperate button, FindControl is used to find all the newly created dropdownlists and get their selected values. The problem is that findcontrol can't find them! I know that the if clause is evaluating to true beacuse the dropdowns are created. But heres what's weird: If i run the CreateDropDowns method in page_load without wrapping it in the if clause that examines the EVENTARGUMENT, then FindControl find them. Whats the difference if its called from within an if clause or not? Either ways, its called from page load. Below is the Java Script on the aspx page:
In the code above, the dropdowns are created but findcontrol can't find them. If I change page load to the following, find control finds them:
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).
Want to ask some answers for my current problem.I have a page which has dynamically created controls on it. 1. One Place holder. (already on page) 2. Two Tables which includes data and textboxes. (Created dynamically and use PlaceHolder.Controls.add to add it on form) 3. One "Save" Asp.net button. (Already created on page but use PlaceHolder.Controls.Add to add it and move its location.) User will fill in some information in the tables' textbox. There will be 12 text box per row and total over 400 rows. (Of course, user will not fill up all textboxes. Just a few 10 or 15 rows and user will enter remaining value in 'The rest: ' textbox.) When user finish, he will press the "Save" button. Problem is after pressing this button, it didn't go to button click event first. It goes to Page_init event first and then comes to button click event. So, in the middle of somewhere, the form is brand new and there is no data inside the textbox when it reached button event. How to prevent this from happen? What I found so far is: I read some post indicate to declare the dynamically controls in Page_Init event instead of Page_Load event. So, I did it. And so when pressing button, it goes to Page_Init and so my dynamic controls all become new.
I have this one window which is a webform for a service request. On the form are buttons that will open another window to allow the user to make choices which will then get returned to the opening window. The problem is that unless the values are returned to textboxes the returned values will get wiped out when you click a button to open another window. Such as the HTML that I return to a label for display purposes.
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.
I have a TabContainer object with 5 tabs. I have autopostback set to true and within all of the <ContentTemplate>'s of the <TabPanel> I have <Panels>. Everything is working fine except I need to prevent the postback on the 3rd tab (I have a hover menu that appears requesting additional information I need for that specific postback). I have tried setting the OnClientClick="return false" on the TabPanel I want to prevent the post back from, but it throws errors and does not display the tabcontainer anymore. Also, this is inside of a UserControl inside of the hosting page.
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.