473,320 Members | 1,746 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Making 1 control invisible while showing another in the exact location of the invisible one

I have 2 TextBoxes and an Add button on a page. When the user fills in the
TextBoxes, the values are added to a dataset table. When the page gets done
reloading, the TextBoxes are turned into readonly mode, the
requiredFieldValidaters are set to disabled, the character counter for each
textbox is made invisible and edit buttons show up next to the read only
textboxes. I want to make the Add button invisible and then make a save
changes button whenever the use clicks on the edit buttons next to the
textboxes. The save changes button should be in the exact same place the
edit buttons are. How do you do this?

Jun 27 '08 #1
5 2014
On 28 May, 00:17, "Andy B" <a_bo...@sbcglobal.netwrote:
I have 2 TextBoxes and an Add button on a page. When the user fills in the
TextBoxes, the values are added to a dataset table. When the page gets done
reloading, the TextBoxes are turned into readonly mode, the
requiredFieldValidaters are set to disabled, the character counter for each
textbox is made invisible and edit buttons show up next to the read only
textboxes. I want to make the Add button invisible and then make a save
changes button whenever the use clicks on the edit buttons next to the
textboxes. The save changes button should be in the exact same place the
edit buttons are. How do you do this?
This can be confusing but you get used to it.

If you place a series of buttons on the web form using the designer,
(or type them in source code) so that they are adjacent without any
segregation via layout tags, then the one that has it's Visible
property set to true will be rendered in that location and the rest
(if the Visible property is set to false) will not be rendered at all.

There are no blank spaces where invisible controls are placed. Page
flow continues as though they never existed.

In spite of the way they appear on the design surface (seeming to
spread themselves across the page because they are all visible at
once) they will effectively overlap in the manner you require.

HTH
Jun 27 '08 #2
On May 27, 4:17*pm, "Andy B" <a_bo...@sbcglobal.netwrote:
I have 2 TextBoxes and an Add button on a page. When the user fills in the
TextBoxes, the values are added to a dataset table. When the page gets done
reloading, the TextBoxes are turned into readonly mode, the
requiredFieldValidaters are set to disabled, the character counter for each
textbox is made invisible and edit buttons show up next to the read only
textboxes. I want to make the Add button invisible and then make a save
changes button whenever the use clicks on the edit buttons next to the
textboxes. The save changes button should be in the exact same place the
edit buttons are. How do you do this?
I've personally done this a few different ways, and Stan's solution
has been one of them. However, I felt like posting an alternative to
his solution both for Andy and anyone else reading this post.

Use the same button for both "Save" and "Edit". The rendered page will
obviously have a single button always in the same place. In this case
I usually set the command name to something useful and have handle the
OnCommand event. This event would check the command name and call the
appropriate function. Actually for your example, the same button can
handle all three states: Add, Read, and Edit. So, when the user first
gets to the page, the button defaults to "Add". Once they add
whatever, the button is changed to "Edit". And when they hit "Edit",
it is changed to "Save".
PRO
It looks good rendered and in design mode.
There is a single handler for button clicks that servers as a "mapper"
to whatever method needs to be called. (Please do NOT put all the code
in the handler, thats ugly)
CON
Have to keep track of the correct CommandName. (AKA more code then
Stan's solution)
The single button's action is essentially late-bound, which is not
always a good idea.

Anyway, that's my two cents. I'm actually curious what anybody else
has o say about this method. Happy coding!

Norm
Jun 27 '08 #3
Do you have more about how to do it this way? I am kind of interested....
"Norm" <ne*****@gmail.comwrote in message
news:50**********************************@c19g2000 prf.googlegroups.com...
On May 27, 4:17 pm, "Andy B" <a_bo...@sbcglobal.netwrote:
I have 2 TextBoxes and an Add button on a page. When the user fills in the
TextBoxes, the values are added to a dataset table. When the page gets
done
reloading, the TextBoxes are turned into readonly mode, the
requiredFieldValidaters are set to disabled, the character counter for
each
textbox is made invisible and edit buttons show up next to the read only
textboxes. I want to make the Add button invisible and then make a save
changes button whenever the use clicks on the edit buttons next to the
textboxes. The save changes button should be in the exact same place the
edit buttons are. How do you do this?
I've personally done this a few different ways, and Stan's solution
has been one of them. However, I felt like posting an alternative to
his solution both for Andy and anyone else reading this post.

Use the same button for both "Save" and "Edit". The rendered page will
obviously have a single button always in the same place. In this case
I usually set the command name to something useful and have handle the
OnCommand event. This event would check the command name and call the
appropriate function. Actually for your example, the same button can
handle all three states: Add, Read, and Edit. So, when the user first
gets to the page, the button defaults to "Add". Once they add
whatever, the button is changed to "Edit". And when they hit "Edit",
it is changed to "Save".
PRO
It looks good rendered and in design mode.
There is a single handler for button clicks that servers as a "mapper"
to whatever method needs to be called. (Please do NOT put all the code
in the handler, thats ugly)
CON
Have to keep track of the correct CommandName. (AKA more code then
Stan's solution)
The single button's action is essentially late-bound, which is not
always a good idea.

Anyway, that's my two cents. I'm actually curious what anybody else
has o say about this method. Happy coding!

Norm
Jun 27 '08 #4
On May 28, 2:35*am, "Andy B" <a_bo...@sbcglobal.netwrote:
Do you have more about how to do it this way? I am kind of interested....

"Norm" <neon...@gmail.comwrote in message

news:50**********************************@c19g2000 prf.googlegroups.com...
On May 27, 4:17 pm, "Andy B" <a_bo...@sbcglobal.netwrote:
I have 2 TextBoxes and an Add button on a page. When the user fills in the
TextBoxes, the values are added to a dataset table. When the page gets
done
reloading, the TextBoxes are turned into readonly mode, the
requiredFieldValidaters are set to disabled, the character counter for
each
textbox is made invisible and edit buttons show up next to the read only
textboxes. I want to make the Add button invisible and then make a save
changes button whenever the use clicks on the edit buttons next to the
textboxes. The save changes button should be in the exact same place the
edit buttons are. How do you do this?

I've personally done this a few different ways, and Stan's solution
has been one of them. However, I felt like posting an alternative to
his solution both for Andy and anyone else reading this post.

Use the same button for both "Save" and "Edit". The rendered page will
obviously have a single button always in the same place. In this case
I usually set the command name to something useful and have handle the
OnCommand event. This event would check the command name and call the
appropriate function. Actually for your example, the same button can
handle all three states: Add, Read, and Edit. So, when the user first
gets to the page, the button defaults to "Add". Once they add
whatever, the button is changed to "Edit". And when they hit "Edit",
it is changed to "Save".
PRO
It looks good rendered and in design mode.
There is a single handler for button clicks that servers as a "mapper"
to whatever method needs to be called. (Please do NOT put all the code
in the handler, thats ugly)
CON
Have to keep track of the correct CommandName. (AKA more code then
Stan's solution)
The single button's action is essentially late-bound, which is not
always a good idea.

Anyway, that's my two cents. I'm actually curious what anybody else
has o say about this method. Happy coding!

Norm
Here is some psuedo-code for you. If you would like more help just
reply, I am watching this thread.
Note: I am using psuedo-VB syntax, and I did this from memory so i
might be off on exact event and/or property names.

CODE BEHIND

' Business Methods
Public Sub Add()
' Set TextBoxes Readonly, disable Validators and Character
counters, add data to datatable
CommandButton.CommandName = "Edit"
CommandButton.Text = "Edit"
End Sub

Public Sub Edit()
' Set TextBoxes editable, enable Validators and Character counters
CommandButton.CommandName = "Save"
CommandButton.Text = "Save"
End Sub

Public Sub Save()
' Set TextBoxes Readonly, disable Validators and Character
counters, modify data in datatable
CommandButton.CommandName = "Edit"
CommandButton.Text = "Edit"
End Sub

Protected Sub DoCommand(sender as object, e as CommandEventArgs)
Handles CommandButton.OnCommand
Select Case e.CommandName
Case "Add"
Add()
Case "Edit"
Edit()
Case "Save"
Save()
End Select
End Sub

PAGE / USERCONTROL

<asp:TextBox ID="Value1TextBox" />
<asp:TextBox ID="Value2TextBox" />
<!-- Validators, Character counters, etc. -->
<asp:Button ID="CommandButton" CommandName="Add" Text="Add" />

Looking at this after I typed it, this might even compile. But that is
the general idea. One button, one event handler, mapped to three
methods. Looks good rendered and in design, and even allows for an
easy way to add functionality. (New? Delete? etc.) Hope I made your
day (and anyone elses) easier!

Norm
Jun 27 '08 #5
I am using c# for programming. I will have to try this way of doing things
out and see how it goes. I did some sort of derivitive of thuis and it seems
to work until I hit the edit button. It seems to be stuck in "AddPreview"
state where the textboxes are readonly and disabled. I will try splitting
things up more like this and let you know how it turns out. Just a note that
I have this all inside a Wizard.
"Norm" <ne*****@gmail.comwrote in message
news:82**********************************@x1g2000p rh.googlegroups.com...
On May 28, 2:35 am, "Andy B" <a_bo...@sbcglobal.netwrote:
Do you have more about how to do it this way? I am kind of interested....

"Norm" <neon...@gmail.comwrote in message

news:50**********************************@c19g2000 prf.googlegroups.com...
On May 27, 4:17 pm, "Andy B" <a_bo...@sbcglobal.netwrote:
I have 2 TextBoxes and an Add button on a page. When the user fills in
the
TextBoxes, the values are added to a dataset table. When the page gets
done
reloading, the TextBoxes are turned into readonly mode, the
requiredFieldValidaters are set to disabled, the character counter for
each
textbox is made invisible and edit buttons show up next to the read only
textboxes. I want to make the Add button invisible and then make a save
changes button whenever the use clicks on the edit buttons next to the
textboxes. The save changes button should be in the exact same place the
edit buttons are. How do you do this?

I've personally done this a few different ways, and Stan's solution
has been one of them. However, I felt like posting an alternative to
his solution both for Andy and anyone else reading this post.

Use the same button for both "Save" and "Edit". The rendered page will
obviously have a single button always in the same place. In this case
I usually set the command name to something useful and have handle the
OnCommand event. This event would check the command name and call the
appropriate function. Actually for your example, the same button can
handle all three states: Add, Read, and Edit. So, when the user first
gets to the page, the button defaults to "Add". Once they add
whatever, the button is changed to "Edit". And when they hit "Edit",
it is changed to "Save".
PRO
It looks good rendered and in design mode.
There is a single handler for button clicks that servers as a "mapper"
to whatever method needs to be called. (Please do NOT put all the code
in the handler, thats ugly)
CON
Have to keep track of the correct CommandName. (AKA more code then
Stan's solution)
The single button's action is essentially late-bound, which is not
always a good idea.

Anyway, that's my two cents. I'm actually curious what anybody else
has o say about this method. Happy coding!

Norm
Here is some psuedo-code for you. If you would like more help just
reply, I am watching this thread.
Note: I am using psuedo-VB syntax, and I did this from memory so i
might be off on exact event and/or property names.

CODE BEHIND

' Business Methods
Public Sub Add()
' Set TextBoxes Readonly, disable Validators and Character
counters, add data to datatable
CommandButton.CommandName = "Edit"
CommandButton.Text = "Edit"
End Sub

Public Sub Edit()
' Set TextBoxes editable, enable Validators and Character counters
CommandButton.CommandName = "Save"
CommandButton.Text = "Save"
End Sub

Public Sub Save()
' Set TextBoxes Readonly, disable Validators and Character
counters, modify data in datatable
CommandButton.CommandName = "Edit"
CommandButton.Text = "Edit"
End Sub

Protected Sub DoCommand(sender as object, e as CommandEventArgs)
Handles CommandButton.OnCommand
Select Case e.CommandName
Case "Add"
Add()
Case "Edit"
Edit()
Case "Save"
Save()
End Select
End Sub

PAGE / USERCONTROL

<asp:TextBox ID="Value1TextBox" />
<asp:TextBox ID="Value2TextBox" />
<!-- Validators, Character counters, etc. -->
<asp:Button ID="CommandButton" CommandName="Add" Text="Add" />

Looking at this after I typed it, this might even compile. But that is
the general idea. One button, one event handler, mapped to three
methods. Looks good rendered and in design, and even allows for an
easy way to add functionality. (New? Delete? etc.) Hope I made your
day (and anyone elses) easier!

Norm
Jun 27 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Saqib Ali | last post by:
Please excuse me, this is a fairly involved question that will likely require you to save the file below to a file and open it in a browser. I use Mozilla 1.5, so the problem I describe below...
3
by: Joshua Ammann | last post by:
Hi, (Using Access 2000) I have two tables, similar to Customers and Orders. (Not an exact parallel, but works for this example.) On a form showing customer data, there is a tab control. One...
4
by: Derrick | last post by:
Hello all; I'm trying to simulate a "scrollable context menu". What I want is to have a listbox fill the entire area of a small form (with no border). Using the designer and property grid, I...
3
by: Dakkar | last post by:
I made a program like i showed below and i used this.Visible = false; line to make it invisible but it doesnt work where did i make mistake ? here is my code
1
by: Amber | last post by:
The DataGrid allows you to make columns visible or invisible on demand - even edit and other special columns. This article will show you how it is done. Some developers have reported problems...
3
by: Sandeep Singh Sekhon | last post by:
I am developing an application in ASP.NET 1.1. on one page I allow the user to upload and delete the files to the server. When I delete the file, I physically delete the file from the location....
2
by: VMI | last post by:
My web app uses the new Wizard control, but I would like to make the sideBar invisible so that the only way a user can navigate through the wizard is through the <Previousand <Nextbuttons. Is this...
1
by: Sunfire | last post by:
I need to know how to position a layout table in code next to (to the right of) another table on the page? I also then need to know how to make it invisible in code. How would you do this?
2
by: OllyJ | last post by:
Hi guys hope you can help... ...do you have any idea how you can set a control's (within a single record in a continuous form) property to visible=false depending on the outcome of an update...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.