This is a huge problem. I'm going insane. I've tried to solve this
elsewhere and no one can suggest how to make this work. To me, this
should be a very basic thing to do.
I have an asp.net application that is a survey acceptor. The site is
to display a page of survey questions and accept the responses. It
builds the entire page dynamically from SQL Server tables. The idea
is that when a person submits their responses, if there are validation
errors, to reload the page with the error text under the question
heading. I have this working. Sort of.
- There are 3 questions, all required. I load the page and answer the
first question only and hit submit.
- The error texts show up! But the question I selected (radio) isn't
selected anymore.
- I choose the first question again and hit submit. The question
remains selected but the errror texts are gone.
This goes back and forth with each click of the button; errors and
noselection, selection and no errors, errors and no selection,
selection and no errors. I'm not understanding something. Here's the
basic flow of the page:
Private Sub Page_Load
BuildPage()
End Sub
Private Sub BuildPage()
' Code to build the page from SQL Server tables.
' Creates controls, HTML elements, a submit button and a handler for
the button click.
' Also checks an array for errors and displays error text:
If Me.IsPostBack = True Then
ErrorString = CheckForError(Q .ID)
If ErrorString <> "" Then
AddLiteral(Erro rString)
End If
End If
' Question text is placed here
' Controls (ie. radios) are placed here
End Sub
Private Sub Submit_Click
' Checks for errors in the page; ie. a question has not been answered.
' Loads an array of question ID's and the errors associated
If ErrorCount > 0 then
PlaceHolder1.Co ntrols.Clear()
BuildPage()
else
response.redire ct("ThankYou.as px")
end if
end sub
So this is how I see this:
- Load the page, build its content in Page_Load
- Fill out, Submit. The server gets the page and executes the button
click code.
- The code checks for errors. Assume there is one.
- Above, Errorcount > 0. It rebuilds the page by clearing the
Placeholder and re-adding the controls. Since this is postback, it
inserts the error texts as it builds and it gets sent back to the
client.
But that's not right somehow because although I do get the error texts
inserted, the selections I did make are cleared. When I hit submit on
this page, it comes back with my selections and no errors. I'm told
that if I build the page in Page_Init, the control states will be
maintained but they aren't.
Where is my thinking going askew?
If it helps to admit I'm a newbie to asp.net and am an idiot then
please, make that assumption. :) 2 1398
if you ever read a piece of sample code on ASP.NET, you will notice that
almost all Page_Load() event handler has a line of code like this:
Private Sub Page_Load()
If Not Page.IsPostBack Then
BuildPage() 'You only need to dynamically biuld the page when the
page is called the first time
Else
'Do something else if necessary when the page is posted back
'Or do nothing, leave processing to other server event handler, such
as Button_Click, DropDownList_Se lectedIndexChan ged...
End If
End Sub
"Tom wilson" <ye*******@nosp am.com> wrote in message
news:uc******** *************** *********@4ax.c om... This is a huge problem. I'm going insane. I've tried to solve this elsewhere and no one can suggest how to make this work. To me, this should be a very basic thing to do.
I have an asp.net application that is a survey acceptor. The site is to display a page of survey questions and accept the responses. It builds the entire page dynamically from SQL Server tables. The idea is that when a person submits their responses, if there are validation errors, to reload the page with the error text under the question heading. I have this working. Sort of.
- There are 3 questions, all required. I load the page and answer the first question only and hit submit. - The error texts show up! But the question I selected (radio) isn't selected anymore. - I choose the first question again and hit submit. The question remains selected but the errror texts are gone.
This goes back and forth with each click of the button; errors and noselection, selection and no errors, errors and no selection, selection and no errors. I'm not understanding something. Here's the basic flow of the page:
Private Sub Page_Load BuildPage() End Sub
Private Sub BuildPage() ' Code to build the page from SQL Server tables. ' Creates controls, HTML elements, a submit button and a handler for the button click. ' Also checks an array for errors and displays error text:
If Me.IsPostBack = True Then ErrorString = CheckForError(Q .ID) If ErrorString <> "" Then AddLiteral(Erro rString) End If End If ' Question text is placed here ' Controls (ie. radios) are placed here End Sub
Private Sub Submit_Click ' Checks for errors in the page; ie. a question has not been answered. ' Loads an array of question ID's and the errors associated
If ErrorCount > 0 then PlaceHolder1.Co ntrols.Clear() BuildPage() else response.redire ct("ThankYou.as px") end if
end sub
So this is how I see this:
- Load the page, build its content in Page_Load - Fill out, Submit. The server gets the page and executes the button click code. - The code checks for errors. Assume there is one. - Above, Errorcount > 0. It rebuilds the page by clearing the Placeholder and re-adding the controls. Since this is postback, it inserts the error texts as it builds and it gets sent back to the client.
But that's not right somehow because although I do get the error texts inserted, the selections I did make are cleared. When I hit submit on this page, it comes back with my selections and no errors. I'm told that if I build the page in Page_Init, the control states will be maintained but they aren't.
Where is my thinking going askew?
If it helps to admit I'm a newbie to asp.net and am an idiot then please, make that assumption. :)
Oh yes, I've tried that:
Private Sub Page_Load(...
if Me.IsPostBack = False Then
BuildPage()
end if
end sub
The results:
1 - Load the page, fill out, submit.
2 - Blank page.
On Fri, 11 Feb 2005 12:54:58 -0700, "Norman Yuan"
<No*****@NotRea l.not> wrote: if you ever read a piece of sample code on ASP.NET, you will notice that almost all Page_Load() event handler has a line of code like this:
Private Sub Page_Load()
If Not Page.IsPostBack Then BuildPage() 'You only need to dynamically biuld the page when the page is called the first time Else 'Do something else if necessary when the page is posted back 'Or do nothing, leave processing to other server event handler, such as Button_Click, DropDownList_Se lectedIndexChan ged... End If
End Sub
"Tom wilson" <ye*******@nosp am.com> wrote in message news:uc******* *************** **********@4ax. com... This is a huge problem. I'm going insane. I've tried to solve this elsewhere and no one can suggest how to make this work. To me, this should be a very basic thing to do.
I have an asp.net application that is a survey acceptor. The site is to display a page of survey questions and accept the responses. It builds the entire page dynamically from SQL Server tables. The idea is that when a person submits their responses, if there are validation errors, to reload the page with the error text under the question heading. I have this working. Sort of.
- There are 3 questions, all required. I load the page and answer the first question only and hit submit. - The error texts show up! But the question I selected (radio) isn't selected anymore. - I choose the first question again and hit submit. The question remains selected but the errror texts are gone.
This goes back and forth with each click of the button; errors and noselection, selection and no errors, errors and no selection, selection and no errors. I'm not understanding something. Here's the basic flow of the page:
Private Sub Page_Load BuildPage() End Sub
Private Sub BuildPage() ' Code to build the page from SQL Server tables. ' Creates controls, HTML elements, a submit button and a handler for the button click. ' Also checks an array for errors and displays error text:
If Me.IsPostBack = True Then ErrorString = CheckForError(Q .ID) If ErrorString <> "" Then AddLiteral(Erro rString) End If End If ' Question text is placed here ' Controls (ie. radios) are placed here End Sub
Private Sub Submit_Click ' Checks for errors in the page; ie. a question has not been answered. ' Loads an array of question ID's and the errors associated
If ErrorCount > 0 then PlaceHolder1.Co ntrols.Clear() BuildPage() else response.redire ct("ThankYou.as px") end if
end sub
So this is how I see this:
- Load the page, build its content in Page_Load - Fill out, Submit. The server gets the page and executes the button click code. - The code checks for errors. Assume there is one. - Above, Errorcount > 0. It rebuilds the page by clearing the Placeholder and re-adding the controls. Since this is postback, it inserts the error texts as it builds and it gets sent back to the client.
But that's not right somehow because although I do get the error texts inserted, the selections I did make are cleared. When I hit submit on this page, it comes back with my selections and no errors. I'm told that if I build the page in Page_Init, the control states will be maintained but they aren't.
Where is my thinking going askew?
If it helps to admit I'm a newbie to asp.net and am an idiot then please, make that assumption. :)
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Maria |
last post by:
Hi
I have a asp:table that I want to hold the values between
postbacks. Hope some one knows how I can get that to work
in an easy way. The table is loaded in runtime with
different textboxes. When i press a button and runs some
server code the page becomes "quite empty"
Thanks in advance
|
by: Novice |
last post by:
Hey all, I have finally managed to create a Custom WebControl and am using a
technique from another programmer to maintain state between pages - I would
just like to validate this idea.
Basically I have created a Custom Web Control that is capable of generating
multiple webpages. It actually only creates one webpage, but hides Panels
(that contain the web controls - TextBox's, Labels, etc) to give the
impression that the user is...
|
by: Justin Crossley |
last post by:
I have a webform that lists search results using an XML control
The search results are contained in a string called strResults and are transformed using an xsl file into formatted results.
The c# code is as follows:
XslTransform trans2 = new XslTransform();
trans2.Load(Server.MapPath("HitList.xsl"));
xmlSearchResults.DocumentContent = strResults;
xmlSearchResults.Transform = trans2;
|
by: Tom wilson |
last post by:
This is a huge problem. I'm going insane. I've tried to solve this
elsewhere and no one can suggest how to make this work. To me, this
should be a very basic thing to do.
I have an asp.net application that is a survey acceptor. The site is
to display a page of survey questions and accept the responses. It
builds the entire page dynamically from SQL Server tables. The idea
is that when a person submits their responses, if there are...
|
by: Deepson Thomas |
last post by:
Hi,
Currently iam facing a strange problem.. One dropdown in my page is
keeping itz state after postback. Whichever the item i selected is not the
selected item after postback. it goes back to the first item again. This
happens even if i submitted the page by making the AutoPostback of the
dropdown true or by clicking on the submit button. Even itz not going to the
DropDownList1_SelectedIndexChanged method.
A checking is already there...
| |
by: Deepson Thomas |
last post by:
Hi,
Currently iam facing a strange problem.. One dropdown in my page is not
keeping itz state after postback. Whichever the item i select irrespective of
that after the post-back the default selected item is the first one. This
happens even if i submitted the page by making the AutoPostback of the
dropdown true or by clicking on the submit button.
Even it’s not going to the DropDownList1_SelectedIndexChanged method.
A checking is...
|
by: Matt MacDonald |
last post by:
Hi All,
I have a form that displays hierarchical categories in a treeview. Ok so
far so good. What I was to do is have users be able to select a node in the
treeview as part of filling out the form. I only want to allow single
selection, so using checkboxes is out of the question. It works as is, but
it makes the form very cumbersome if every time that a user selects a node,
the whole page has to reload. Is there a way to have a node...
|
by: John Kotuby |
last post by:
Hi guys,
I am converting a rather complicated database driven Web application from
classic ASP to ASP.NET 2.0 using VB 2005 as the programming language. The
original ASP application works quite well, so at times it is tempting just
to port parts of it over mostly as-is. In fact, one MSDN article I read
suggested using straight HTML wherever possible to make the app more
efficient and less resource demanding.
On one page there are 2...
|
by: Pselus |
last post by:
I have a form that is built pretty much entirely at run time.
I load a collection of Categories which have multiple Plans.
Each Plan has a RadioButton.
Each Category has a single PriceTag TextBox that is populated with a
Price when a RadioButton is selected. This is done through a
Javascript method.
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| | |