Restoring Old Value Of A Textbox (or Any Other Control)?

Mar 4, 2010

I have an ASP.NET page with a textbox and a button. In the textbox I enter let's say a name "Laurel" and click the button. The textbox is related as a control parameter to a data source and this data source pulls the content "Laurel" from the textbox to build a query, selects all orders of customer Laurel and sends them back to the browser where they are displayed in a list (gridview for instance). The list is long and has two pages (the list has a pager control). The list is on the same page where also the textbox is located. So I see now a page in my browser with the textbox (still containing the text "Laurel") and a list with a pager.

I could do now two actions:

Enter the name "Hardy" in the textbox and click on the button: The cycle above runs again and orders of customer Hardy are displayed. That's fine and what I want. Click on the pager control to display the second page of Laurel's orders. This works because I still have "Laurel" in the textbox. So on the postback triggered by the pager control the data source can extract again "Laurel" as query parameter from the textbox, run the query and deliver the second page of orders to my browser. That's fine too.

Actually there could be a third action:

I enter the name "Hardy" in the textbox, then change my mind and decide that I want to see the second page of Laurel's order. So I have "Hardy" in the textbox but don't click the submit button but instead I click on "next page" of the pager control to view the second page. On the server the data source extracts the content "Hardy" of the textbox, runs a query and then tries to deliver the second page of Hardy's instead of Laurel's orders. So that's not what I want. (Perhaps Hardy has only a few orders, not enough for two pages. The data source might tell me then "Nothing found" because there is nothing on the second page for Hardy.)

(What I mean can also be seen here on stackoverflow: Enter something in the search box, for instance "ASP.NET" and hit the enter key, you'll get a long result list with many pages. Then enter another term in the searchbox, for instance "PHP" but don't hit enter, instead click on page 2 in the pager control on bottom of the page. A postback occurs (which also transmits the new content "PHP" of the searchbox, I guess), the second page for keyword "ASP.NET" is displayed and the searchbox doesn't contain "PHP" anymore but instead again "ASP.NET".)

Question is now: How can I avoid a situation like this? My basic idea is: I need to restore the old value "Laurel" in the textbox to provide the correct parameter value to the data source query and my old value "Laurel" must be stored "somewhere" (on server? where on server? on client? if on client, hidden in the page or in a cookie or... ?). Are there some standard patterns to deal with this requirement? Or am I thinking in the wrong direction?

View 2 Replies


Similar Messages:

Web Forms :: Restoring User Control Property Values Upon Postback?

Jun 9, 2010

I'm constructing a User Control that will have one Property called "ContractIdx". Here's how I've constructed this Property:

public int ContractIdx
{
get
{
return Convert.ToInt32(this.Attributes["ContractIdx"]);
}
set
{
this.Attributes["ContractIdx"] = value.ToString();
}
}

I'm initially loading the User Control by passing a parameter to it and setting ContractIdx accordingly. That all works fine.

Upon Postback though I'm loading the User Control without any parameters and then setting its ID property to what it was before the Postback. My understanding was that if I did this then ViewState would properly restore everything. Yet apparently this is not the case with the "ContractIdx" attribute.

Where am I mistaken in my understanding? How should I change things to get this mechanism to work?

View 5 Replies

State Management :: Custom Control: State Restoring For Controls Created With CreateChildControls

Dec 22, 2010

Let me explain, describing the scenario:In a custom server control (in my case, derived from CompositeControl), in the overidden CreateChildControls method I create a complex tree of subcontrols, using information from a db.The db provides both information on which controls I need to create (the user interface's structure) and the data used to fill these controls.Than the user can interact with the control and change the data (that becomes different to what stored on db).

My custom control lives in the same page where there are other controls, obviously.And these controls can cause a postback at any time.What I need is that my custom control keeps the data entered by the user across these postback, without reverting to the original data and loose the user data entry.

Here is the first doubt:

1)I create the subcontrols dinamically in the CreateChildControls at any page refresh (both on first call than on postback).I know that the framework solves the reference between the posted data and the controls I create in the CreateChildControls in order to set properties and raise control events, but can you tell me when and how it actually does this? In which phase of page life cycle? What happens after the CreateChildControls?

A second doubt:2)If the user interface structure must change as a consequence of the data entered, I had to execute CreateChildControls twice (the first time to recreate the original interface to get the events and the second time to create the new interface)
In which phase of page/control lifecycle do I have to make the second call to CreateChildControls? I do it on Prerender now, but is it right or wrong, and why?

View 1 Replies

Restoring From A Server File?

Apr 20, 2010

I have just opened my project and a RadAjaxLoadingPanel has got an error on it and deleted everything that was in it...

There is nothing in the design view or source view now...

I opened my back up from last night, and that is the same...

I opened my backup from Friday night and that is OK, BUT it will mean re-doing al of yesterday's work and a few hours from the weekend...

I tried copying the page from the server (I had uploaded the site last night and it's working fine), but when I try and open it I get 'This is a marker file generated by the precompilation tool, and should not be deleted!'...

Is there anyway to restore my page from the page sitting on the web server..?

View 2 Replies

.net - Saving And Restoring Xml Differences?

Jan 13, 2010

I am using asp.net and the .net framework 2.0. I may be able to upgrade the servers to 3.5 if the solution is compelling enough. Here is the problem.I have two pieces of xml.I'll refer to piece number 1 as the template and piece number 2 as the actual.Here's a basic example:template:

<questions>
<question1 msg="1234">
<answer></answer>

[code]...

View 2 Replies

WebMatrix :: Restoring The Textarea Value?

Mar 25, 2011

I have a html textarea in my form, and when I postback the form, the value of textarea gets lost. I want the value of this textarea to be restored.I know that for restoring the value of textbox, I can directly use value=@Response["TextBoxName"], but this is not valid for text area, so I request you to suggest me a solution.

View 5 Replies

ADO.NET :: Restoring A Server Database Through Code?

Nov 1, 2010

I'm trying to restore a sql server 2k8 database from a .bak file. I've tried using two methods and both are unsuccessful. I've tried using the SMO classes and the error that I get is simply "restore failed for <serverName>". I also tried to simply run a query with the proper syntax for restoring a database. This runs but I get an error message that says the timeout expired. I tried extending the timeout through the connection string to 20 mins but it still fails within a minute.

This is my code:

SMO Method:

[Code]....

SQL Method:

[Code]....

View 3 Replies

Web Forms :: Radio Button Is Not Restoring When Reset?

Nov 18, 2010

I have problem when resetting the radio button.

3 radio buttons with search option and a reset button.

When clicking reset buttion , I will select the first radion button and reset the system. But the functionality is working based on the first radio button, but its not checked. It is checked in the previous state. check in the below website.

[URL]

Click on "Add stuff" , Then search widgets , here you can see the section what i said before. click on the search , you can see the list of widgets and select the "My widgets" and click search , you can see "No widgets found"... now when you click the reset button you can see the list of widgets which are related to the first "All Widgets" radio button,but the radio button is still in the previous state even though i set Allwidgets.checked = true; May i know why its not working?

View 6 Replies

Saving And Restoring Rich Text To/from Database?

Feb 17, 2011

I am creating a winform app in C# to store formatted text from a rich text box to MySQL database, which can be retrieved back to the rich text box. The database field is a VARCHAR and my code is something similar to below. But I'm getting "file not in correct format" error. Can anyone tell what could be the problem? Is the VARCHAR field okay to store it or should I change it to a BLOB?

string rtfText = this.richTextBox1.Rtf;
// save rtfText to database field as varchar
// ...
// reload rtfText from database as string
this.richTextBox1.Rtf = rtfText;

View 4 Replies

Restoring Web Reference In Visual Studio 2008

Feb 18, 2010

I had a web reference set in my VS2008 ASP.NET project, but due to some source control weirdness it is no longer listed in the project. I have the set of files in the Web References folder under my project. There's a .wsdl, .disco and several .datasource files. Is there any way to re-add this web reference through the existing files rather than using the "Add Web Reference" dialog?

View 1 Replies

DataSource Controls :: Restoring The Backup Of One Database To Another?

Jan 24, 2010

I have two databases- database1 and database2. I have taken the full backup of database1 and want to restore it to the database2. When I do it in the Sql server Management Studio, I get this error:

The backup set holds a backup of a database other than the existing 'database2' database.

View 4 Replies

Restoring Dynamically Created Javascript Table Structure

Feb 9, 2011

On runtime I am creating table structure using javascript and appending it to the div which is placed in an update panel. Problem here is, when I use asp.net button control, onClick of the button it posts the page to server and whatever javascript tables I have created it goes off. When I use html input button (input type="button") I don't face this problem and tables also stay there. But I have to use asp.net button to take necessary actions on the server side. Is there any way that I can restore the structure or use asp.net button control alongwith dynamic javascript.

View 1 Replies

VS 2010 - Restoring Entire Listbox From Session Variable

Dec 31, 2011

In my opening page of a web app I create (from a database get) two somewhat large datasets for 2 listboxes. I populate and databind them and all is good with the world

I then want to take those 2 listbox datasets and put them into a session variable for use on other pages of the web app. The reason is I do not want those additional hits in populating the two listboxes again (data does not change)

I am calling a class and passing back a DATASET for each listbox .. then

Session (DATASET_1) = MyClass.Dataset1
Session (DATASET_2) = MyOtherClass.DataSet2
DATASET_1 AND DATASET_2 are defines as constants with a type of DS

When I attempt to rebind the listboxes as

ListBox1.DataSource = Session( DATASET_1 ) *AS System.Data.DataSet ListBox.DataBind()

and the same deal for listbox 2 nothing happens........

View 5 Replies

Forms Data Controls :: Restoring Gridview State After Going To A DetailsView To Edit?

Dec 15, 2010

I have a Gridview that is filtered by a DropDownList.

A sales rep can select all prospects or filter on the first letter of the company name.

They can also sort the complete list or filtered by sales rep name.

There are several reps in the list

It was requested that once the list is filtered by the first letter of the name

and sorted by the sales rep, that once they select a customer to edit in the DetailslView, and that

edit is completed by closing the detailsview, they return to the same sorted list. they return

to the same filtered list but the sort is back to the default which is the company name.

Here's what is in the code behind file.

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Session["selection"] != null)
{

[Code]....

View 4 Replies

C# - Using Bind In TextBox Renders Bound Data Outside The TextBox Control?

Jul 30, 2010

I have a ListView (in an update panel) bound to an ObjectDataSource (connected to an NHibernate object) and in the EditItemTemplate I use Text='<%# Bind("HideLocation")%>' to bind to a string property of the object.

When I click edit (twice, another issue I'm having) and view the code in Chrome, the output looks like this:

[code]....

why the value of the bound data (in this case: In locker 2317) is showing up outside of the text box instead of as the contents of the data?

View 1 Replies

Vb.net - Want To Let TextBox Control TextChanged Event Fire Only When There Are More Than One Character In The TextBox?

Mar 10, 2010

I want to let TextBox control TextChanged event fire only when there are more than one character in the TextBox.

View 2 Replies

How To Put Control Over A Textbox So That Type Only Texts In The Textbox

Feb 28, 2010

1. How can I put control over a textbox so that I can type only texts in the textbox when the input property is set to text only and type only numbers (int or float or uint) when the input property is set to numbers only and get the alert that the ( Only texts/ numbers)? I want to know the property name of the textbox in visual studio 2005/2008 also the alert setting process.

View 1 Replies

Web Forms :: Handling "browser Back Button" And Restoring The State Of The Controls?

Feb 11, 2010

I've a checkbox and a label in a page. If check/uncheck the checkbox the label's text is updated such as "Checked/UnChecked".Here is my problem. The page loads initially with the checkbox unchecked. So after i check it and the postback occurs it shows as checked. But if i click the browser back button, the label is getting revoked to its original state before the postback (showing the text as 'unchecked'), but the checkbox is not getting back to its unchecked.I know that this is the native behavior. But can i write any javascript fix to get this thing done?

View 9 Replies

SQL Server :: Restoring A 2008 Database In A 2000 Database?

Sep 6, 2010

I've been trying to restore a SQL Server 2008 database in SQL Server 2000 and it seems impossible. Does anyone know how to do it or maybe will be able to point me in the right direction?

View 3 Replies

AJAX :: How To Get An Array Of All The Textbox Control Inside Create User Wizard Control

Aug 10, 2010

How can I get all the textboxes inside a create user wizard control using getElementsByTagName().

Below is my JQuery code:

[Code]....

The above code isn't displaying hint text when the textbox retreives focus.

I think there is something wrong with this getElementsByTagName("asp:TextBox"); , I have also tried getElementsByTagName("TextBox"); , getElementsByTagName(":textbox"); and getElementsByTagName("input"); .

But no one of them gets the textboxes array.

Can anyone tell what will be the correct syntax for getting all the textboxes inside a create user wizard control using getElementsByTagName()?

View 3 Replies

Web Forms :: How To Find Textbox Control Inside DetailsView Control Using Javascript

Mar 23, 2010

how to find Textbox Control inside DetailsView Control Using Javascript, I tried below but gives an error OBject reference not found

document.getElementById('<%=DetailsView1.FindControl("TextBox1").ClientID%>');

View 3 Replies

Web Forms :: Extend TextBox Control To Include A BaseValidator Control?

Mar 31, 2010

I have an implementation of a textbox which inherits from the TextBox control. It currently has some features built in to validate text by some JavaScript that is injected when the control is created. I want to modify this so that the control uses the ASP.NET validation controls (eg. RequiredFieldValidator) instead. Is this possible? Is there a place in the lifecycle of the control where I can programmatically create a BaseValidator control and add it to the form? I want to implement this in my textbox control, rather than each specific page that the textbox is on.

View 4 Replies

AJAX :: How To Bind Textbox Control To ComboBox/DropDown Control

Jul 12, 2010

I am using AJAX ComboBox control (or I can use simple ASP.NET DropDown Control it does not matter) in my form. What I do is, I bind combo box control to my database and retrieve client names:

[Code]....

But here is the problem. I want First and Last names to go into separate TextBox controls (txtFirstName and txtLastName). Now it inserts Last Name and Firts Name in txtLastName control. At the same time I would really like to keep LastName + FirstName together in Combo Box.

View 2 Replies

Web Forms :: Create A Textbox And Button Control In Treeview Control

Dec 13, 2010

I was working with treeview and bumped into this problem where i need to add child nodes to a treeview control,these child nodes are a combination of textbox and button control so that

i should be able to save the text as new child control,i tried overiding the pre render and post render text but didn't get the solution.

View 1 Replies

Calendar Control - Display Date Inside A Textbox Control

Oct 23, 2010

NET. The calendar control is displayed in a popup window when pressing abutton and the selected date will be displayed inside a Textbox control.

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved