I have a form in which clicking the submit button calls a "SaveData" sub
rountine I wrote. The SaveData rountine inserts data from the form into a
table and grabs the ID of the newly inserted record and stores it in a
variable in the routine. The routine writes the data to the table just
fine. But one of the last thing lines in my routine is this:
ViewState("id") = intPurchaseOrde rID
The intPurchaseOrde rID is the ID of the brand new record. I'm storing this
in viewstate b/c when the form posts to itself, I essentially want the page
to refresh with the form's fields containing the provided data. I'm also
doing this so they can modify their data before "finalizing " it. The form
also contains a "Finalize" button which will create and send an email and
redirect to a new page.
I'm using ViewState("id") to determine IF the page has already gone thru the
save data routine at least once. IF this "id" is detected, I'm trying to
enable the "Finalize" button which is disabled by default AND replace the
INSERT statement with an UPDATE statement so the record is updated instead
of inserting a new record.
My problem is (finally getting to it) is that I cannot seem to "detect" my
ViewState("id") using a IF statement in the Page_Load routine. However,
when I response.write the ViewState("id") to the page, it's
there..containi ng the correct record ID.
Any ideas as to why the viewstate("id") is being set properly as far as I
can tell but I cannot perform any kind of comparison against it??
Sub Page_Load(Sende r As Object, E As EventArgs)
If Not Page.IsPostBack Then
'Call Sub Routine to prefill some dropdowns on form
End If
Dim intReqID As Integer
intReqID = CInt(ViewState( "id"))
'No ID was detected....mus t be a new page loaded...
If intReqID < 1 Then
btnSubmit.Enabl ed = False
Else
btnSubmit.Enabl ed = True
End If
End Sub 1 2013
I think you're interested in the IsPostBack() function?
--
Thanks,
Eric Lawrence
Program Manager
Assistance and Worldwide Services
This posting is provided "AS IS" with no warranties, and confers no rights.
"D. Shane Fowlkes" <sh********** @h-o-t-m-a-i-l.com> wrote in message
news:eQ******** ******@tk2msftn gp13.phx.gbl... I have a form in which clicking the submit button calls a "SaveData" sub rountine I wrote. The SaveData rountine inserts data from the form into a table and grabs the ID of the newly inserted record and stores it in a variable in the routine. The routine writes the data to the table just fine. But one of the last thing lines in my routine is this:
ViewState("id") = intPurchaseOrde rID
The intPurchaseOrde rID is the ID of the brand new record. I'm storing
this in viewstate b/c when the form posts to itself, I essentially want the
page to refresh with the form's fields containing the provided data. I'm also doing this so they can modify their data before "finalizing " it. The form also contains a "Finalize" button which will create and send an email and redirect to a new page.
I'm using ViewState("id") to determine IF the page has already gone thru
the save data routine at least once. IF this "id" is detected, I'm trying to enable the "Finalize" button which is disabled by default AND replace the INSERT statement with an UPDATE statement so the record is updated instead of inserting a new record.
My problem is (finally getting to it) is that I cannot seem to "detect" my ViewState("id") using a IF statement in the Page_Load routine. However, when I response.write the ViewState("id") to the page, it's there..containi ng the correct record ID.
Any ideas as to why the viewstate("id") is being set properly as far as I can tell but I cannot perform any kind of comparison against it?? Sub Page_Load(Sende r As Object, E As EventArgs) If Not Page.IsPostBack Then 'Call Sub Routine to prefill some dropdowns on form End If
Dim intReqID As Integer
intReqID = CInt(ViewState( "id"))
'No ID was detected....mus t be a new page loaded... If intReqID < 1 Then btnSubmit.Enabl ed = False Else btnSubmit.Enabl ed = True End If
End Sub This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Gregory L. Hansen |
last post by:
I can't seem to make a queue of objects, using the STL queue. I'm trying
to make a little event manager, and I just want someplace to store events.
The method definitions for EventManager have been commented away to
nothing during debugging, but the headers look like
class Event
{
private:
Object* recipient;
int eventID;
|
by: ed |
last post by:
i'm having trouble with a form. I want to be able to type in the address of
the form with the data for the form items in the URL (ie:
http://somesite.com/formpage.html?field1=data1&field2=data2).
It saves the data if I type it in manually to an html file. But it won't do
that if I use the URL notation above. How do I get it to do this. The HTML
for the form is below.
Thank in advance,
ed
|
by: John Kirksey |
last post by:
I have a page that uses an in-place editable DataGrid that supports sorting and paging. EnableViewState is turned ON. At the top of the page are several search fields that allow the user to filter the results in the grid.
Say you filter the grid for records that have a certain condition set to "NO" (in this case a checkbox). In this scenario the search returns one result. If I then check the checkbox ("YES") and save it, I now get my message...
|
by: Hypo |
last post by:
Im relatilvly new to a web programming in general, and
here's the situation i have:
I have a default page with dynamic content, and one
button with onclick code something like this:
{
// do some processing...
Serever.Transfer("second_page.aspx");
// or Response.Redirect("second_page.aspx"); same in
|
by: hitendra15 |
last post by:
Hi
I have created web user control which has Repeater control and
Linkbutton in ItemTemplate of repeater control, following is the code
for this control
On first load it runs fine but when page gets post back it gives
following error
Failed to load viewstate. The control tree into which viewstate is
| |
by: sdrouins |
last post by:
Hello,
I had a really weird problem that occured on one of our site. (occur 2 times
in 3 years)
The client 1 have fill the form1 and submit it, for some reason the page was
postback to the client 1 but the informations that was on the form after the
postback was not the informations of the client 1 but the informations of
another client (on another computer) that had filled this form 5 minutes
before.
|
by: Amoril |
last post by:
I've read quite a few different message on various boards and for some
reason I'm still having trouble wrapping my head around this viewstate
maintenance and trying to get these dynamically created link buttons
to stay wired up to their click events.
I have what is basically a simply survey question generation page. The
page first displays a few static fields and a dropdownlist of various
options for the user to select. When the user...
|
by: grassh0pp3r |
last post by:
Hello,
I'm trying to make a very simple comments page on my site using PHP and am having problems somewhere. I am very new to PHP. I was able to create one that works with comments appended, but I want the latest comment to be on top, and that's where I'm running into trouble. Since I know very little about PHP, I thought I was clever in what I came up with. I think it can work if I get the coding right. Let me know if my logic is wrong. I'm...
|
by: Nick C |
last post by:
Hi
How can i reduce the viewstate for my asp.net application. It is getting
very large now. What is a good solution?
thanks
N
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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: 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: 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...
| |