| | |
How to pass value from locally to globally
Please support our ASP.NET advertiser: Intel Parallel Studio Home
Thread Solved |
Hidden fields are not displayed by the browser, there are a number of uses for them. When dealing with forms you will usually find yourself using some sort of database mechanism: MySQL, SQL Server, or maybe justa plain text file. In any case use hidden forms to pass along information to your database that may have already been received from the user. In this rare case, a hidden form field may come in handy.
A hidden HTML field is used to pass along variables w/ values from one form to another page without forcing the user to re-enter the information. Use the type attribute to specify a hidden field.
There is no display of your hidden field in the box because the browser is told to hide them from view. Our field above is incomplete and pretty much useless as it is. Adding a name and a value attribute will change this.
Naming your fields can be accomplished in two different ways discussed previously. Use the id or name attribute to specify a name for your hidden field.
Above we have demonstrated 3 possible hidden fields that you may want to pass along some form at some point, especially if you have any kind of user base where returning users must log in. The admin field could be used to check some sort of user level entry of a returning user; 1 being administrator and 0 being non-administrator access.
Use hidden fields when you have variables you want to pass from one form to another without forcing the user to re-type information over and over again.
This tutorial is available from www.tizag.com
**********
15 minutes of research can save you 50% or more. forum.feodorgeorgiev.com
A hidden HTML field is used to pass along variables w/ values from one form to another page without forcing the user to re-enter the information. Use the type attribute to specify a hidden field.
ASP.NET Syntax (Toggle Plain Text)
<input type="hidden" />
There is no display of your hidden field in the box because the browser is told to hide them from view. Our field above is incomplete and pretty much useless as it is. Adding a name and a value attribute will change this.
Naming your fields can be accomplished in two different ways discussed previously. Use the id or name attribute to specify a name for your hidden field.
ASP.NET Syntax (Toggle Plain Text)
<input type="hidden" id="age" name="age" value="23" /> <input type="hidden" id="DOB" name="DOB" value="01/01/70" /> <inpyt type="hidden" id="admin" name="admin" value="1" />
Above we have demonstrated 3 possible hidden fields that you may want to pass along some form at some point, especially if you have any kind of user base where returning users must log in. The admin field could be used to check some sort of user level entry of a returning user; 1 being administrator and 0 being non-administrator access.
Use hidden fields when you have variables you want to pass from one form to another without forcing the user to re-type information over and over again.
This tutorial is available from www.tizag.com
**********
15 minutes of research can save you 50% or more. forum.feodorgeorgiev.com
•
•
Join Date: Jun 2007
Posts: 19
Reputation:
Solved Threads: 0
Thanks for your reply,But what i really want is..
Let me explain..
I declare a global variable say flag which is boolean.Then i am assigning true value on button click event of button say Add and on Edit the value of flag is false. Now I want to use value of flag in another button click event say button Save.But the value is not passing from Add Button to Save Button.
I tried using hidden values but not getting then also.
Let me explain..
I declare a global variable say flag which is boolean.Then i am assigning true value on button click event of button say Add and on Edit the value of flag is false. Now I want to use value of flag in another button click event say button Save.But the value is not passing from Add Button to Save Button.
I tried using hidden values but not getting then also.
What environment are you using? .NET and C#? Could you straighten your metacode a bit, so i can understand where exactly are you going with it? Give me the whole picture - purpose of the page, and what are your business rules for the page. Once we have this, i can easily help you solve your problem.
******************
15 minutes of research can save you 50% or more. forum.feodorgeorgiev.com
***Need Web Hosting?
******************
15 minutes of research can save you 50% or more. forum.feodorgeorgiev.com
***Need Web Hosting?
******************
•
•
Join Date: Jun 2007
Posts: 19
Reputation:
Solved Threads: 0
I am using Visual Studio .net 2003.
There is a form containing many buttons like add, save, edit, delete,undo,find and four more buttons which fetch the data like on button << it will show first data from database.On >> this button it will show last data of database, on < it will show previous data of the exsting showing data and > will show next data of the existing.
Now what I want to do is on clicking add button all controls will come in enable mode so user can write in textboxes for adding a new data, then on clicking save it will add to database and similarly on clicking edit the data which the form is showing will allow user to edit and on clicking save it will be edited in database. But now question is how save button will identify that adding will be done or editing,So I declared a global variable say flag which is boolean. Now on clicking add button flag will be true and on edit it will have value false. But the value is not retained by the flag.So how to retain the value of flag so it can be used by the save button.If you have any idea than tell..
There is a form containing many buttons like add, save, edit, delete,undo,find and four more buttons which fetch the data like on button << it will show first data from database.On >> this button it will show last data of database, on < it will show previous data of the exsting showing data and > will show next data of the existing.
Now what I want to do is on clicking add button all controls will come in enable mode so user can write in textboxes for adding a new data, then on clicking save it will add to database and similarly on clicking edit the data which the form is showing will allow user to edit and on clicking save it will be edited in database. But now question is how save button will identify that adding will be done or editing,So I declared a global variable say flag which is boolean. Now on clicking add button flag will be true and on edit it will have value false. But the value is not retained by the flag.So how to retain the value of flag so it can be used by the save button.If you have any idea than tell..
•
•
Join Date: May 2007
Posts: 18
Reputation:
Solved Threads: 1
Viewstate is helpful when you remain within one page (including when you return there by postback). But it is destroyed when you are leaving the page.
in first click processing method you store your value to viewstate
Viewstate["myValue"] = someValue (may be any type)
in the second click processing method you read your value
MyType someValue = (MyType)Viewstate["myValue"];
in first click processing method you store your value to viewstate
Viewstate["myValue"] = someValue (may be any type)
in the second click processing method you read your value
MyType someValue = (MyType)Viewstate["myValue"];
save and edit is the same thing, no? Why cant you do the appropriate checks on the sql server side?
Last edited by sibir1us; Jun 29th, 2007 at 1:14 pm.
******************
15 minutes of research can save you 50% or more. forum.feodorgeorgiev.com
***Need Web Hosting?
******************
15 minutes of research can save you 50% or more. forum.feodorgeorgiev.com
***Need Web Hosting?
******************
![]() |
Other Threads in the ASP.NET Forum
- Previous Thread: Time setting
- Next Thread: Google Checkout
| Thread Tools | Search this Thread |
Tag cloud for ASP.NET
.net 2.0 ajax alltypeofvideos anathor appliances application asp asp.net bc30451 beginner box browser button c# cac checkbox commonfunctions control dataaccesslayer database datagridview datalist deployment development dgv dialog dropdownlist dynamic dynamically edit editing embeddingactivexcontrol expose feedback fileuploader fill findcontrol flash form formatdecimal formview google gridview gudi iis image javascript list listbox login microsoft mobile mouse mssql news novell numerical opera panelmasterpagebuttoncontrols parent project radio redirect registration relationaldatabases reportemail richtextbox rows schoolproject search security select sessionvariables silverlight smoobjects software sql-server sqlserver2005 ssl suse textbox tracking treeview unauthorized validatedate validation vb.net video videos vista visualstudio web webapplications webdevelopemnt webdevelopment webprogramming webservice xsl youareanotmemberofthedebuggerusers





