473,415 Members | 1,562 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,415 software developers and data experts.

Question on textbox property.

Hi. I've also posted this at another discussion board and here is the
original question.

-------------------------
"I have this problem and I don't know what I can do. First of all, I have a
page with [ok] and [cancel] button, and 5 <asp:TextBox>'s and when an user
makes changes to each of the textbox content, javascript client side code is
triggered to change the textbox background color property to some other
color. My problem is when I click on the save button(server side), I get a
pop up window (like a message box but it's just a another browser) that ask
if you would like to save. At this point, if [cancel] is selected, the window
will close and the original page with those textbox will show. However, all
the colors that were changed by client side code is now lost because of
postback to server. Is there anyway to keep the textbox control's property
such as (textbox1.style.backgroundColor) when performing postback. What I
tried so far is to store each of the control's name in hidden value
("textbox1;textbox4") but, can't do anything about it further once I have it
on the server side. Is there any other way to achieve this. Any help would
be appreciated. Thanks."

Henry

Nov 19 '05 #1
3 1683
you are on the right track. onpostback, read the hidden field, and set the
style in serverside code. alternately do in client side code, on postback
render a call to client script that does it.

-- bruce (sqlwork.com)
"Henry" <He***@discussions.microsoft.com> wrote in message
news:81**********************************@microsof t.com...
| Hi. I've also posted this at another discussion board and here is the
| original question.
|
| -------------------------
| "I have this problem and I don't know what I can do. First of all, I have
a
| page with [ok] and [cancel] button, and 5 <asp:TextBox>'s and when an user
| makes changes to each of the textbox content, javascript client side code
is
| triggered to change the textbox background color property to some other
| color. My problem is when I click on the save button(server side), I get
a
| pop up window (like a message box but it's just a another browser) that
ask
| if you would like to save. At this point, if [cancel] is selected, the
window
| will close and the original page with those textbox will show. However,
all
| the colors that were changed by client side code is now lost because of
| postback to server. Is there anyway to keep the textbox control's
property
| such as (textbox1.style.backgroundColor) when performing postback. What I
| tried so far is to store each of the control's name in hidden value
| ("textbox1;textbox4") but, can't do anything about it further once I have
it
| on the server side. Is there any other way to achieve this. Any help
would
| be appreciated. Thanks."
|
| Henry
|
Nov 19 '05 #2
Alternatively, you could write Javascript code that gets run on Window's
OnLoad event. This will "re-play" the color coding of the text boxes based
on the current values. Does the server NEED to know about the color changes?
If so, this approach will not work.

Also, when you change the colors, you could also write cookies in
Javascript. When posting back, the cookies will be sent to the server. The
page then needs to read the cookies determine the colors. This approach will
work if it's required that the server know about the color coding. You can
do a quick google on something like "write cookie javascript" to get sample
code on writing the cookies.

Hope that helps

Steve

"Henry" <He***@discussions.microsoft.com> wrote in message
news:81**********************************@microsof t.com...
Hi. I've also posted this at another discussion board and here is the
original question.

-------------------------
"I have this problem and I don't know what I can do. First of all, I have a page with [ok] and [cancel] button, and 5 <asp:TextBox>'s and when an user
makes changes to each of the textbox content, javascript client side code is triggered to change the textbox background color property to some other
color. My problem is when I click on the save button(server side), I get a pop up window (like a message box but it's just a another browser) that ask if you would like to save. At this point, if [cancel] is selected, the window will close and the original page with those textbox will show. However, all the colors that were changed by client side code is now lost because of
postback to server. Is there anyway to keep the textbox control's property such as (textbox1.style.backgroundColor) when performing postback. What I
tried so far is to store each of the control's name in hidden value
("textbox1;textbox4") but, can't do anything about it further once I have it on the server side. Is there any other way to achieve this. Any help would be appreciated. Thanks."

Henry

Nov 19 '05 #3

Thanks for the reply. Since I'll do this setting while in page_load
routine, how would I go about setting my server-side textbox control's style
base on what I have in my hidden value?

Protected WithEvents textbox1 As System.Web.UI.WebControls.TextBox
Protected WithEvents textbox2 As System.Web.UI.WebControls.TextBox
Protected WithEvents textbox3 As System.Web.UI.WebControls.TextBox
Protected WithEvents textbox4 As System.Web.UI.WebControls.TextBox

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If Not Me.IsPostBack Then

Else
Dim myArray As Array
' assuming that Request.Form("hidChangedCol") is "textbox1:textbox4"
myArray = Split(Request.Form("hidChangedCol"), ":")
For j = 0 To myArray.Length - 2
''???????? textbox style settings..such as textbox1.Style("BackColor") =
"Red", etc...
Next
End If

End Sub
Or alternately, could you please clarify what you mean by client side code
from postback? Thanks again.

Henry.

"bruce barker" wrote:
you are on the right track. onpostback, read the hidden field, and set the
style in serverside code. alternately do in client side code, on postback
render a call to client script that does it.

-- bruce (sqlwork.com)
"Henry" <He***@discussions.microsoft.com> wrote in message
news:81**********************************@microsof t.com...
| Hi. I've also posted this at another discussion board and here is the
| original question.
|
| -------------------------
| "I have this problem and I don't know what I can do. First of all, I have
a
| page with [ok] and [cancel] button, and 5 <asp:TextBox>'s and when an user
| makes changes to each of the textbox content, javascript client side code
is
| triggered to change the textbox background color property to some other
| color. My problem is when I click on the save button(server side), I get
a
| pop up window (like a message box but it's just a another browser) that
ask
| if you would like to save. At this point, if [cancel] is selected, the
window
| will close and the original page with those textbox will show. However,
all
| the colors that were changed by client side code is now lost because of
| postback to server. Is there anyway to keep the textbox control's
property
| such as (textbox1.style.backgroundColor) when performing postback. What I
| tried so far is to store each of the control's name in hidden value
| ("textbox1;textbox4") but, can't do anything about it further once I have
it
| on the server side. Is there any other way to achieve this. Any help
would
| be appreciated. Thanks."
|
| Henry
|

Nov 19 '05 #4

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

Similar topics

3
by: Frank Wisniewski | last post by:
I have the following persudo code: //My Form Class class Form1 { //Local Variable for my custom object private MyCustomObject1 //Constructor for Form Class public Constructor{
6
by: wASP | last post by:
Hello everyone, I'm new to C# and ASP.NET, so pardon my stupidity on this one. I'm having a problem with referencing methods/functions external to a class member function. My code is as...
6
by: Stuart Ferguson | last post by:
Is there a way from a textbox that you can establish the maximum length of the text that will be displayed in the textbox on the screen. What i am not requring is the Max Length of the Textbox...
6
by: Chris | last post by:
I've created two textboxes and one button on my web form. I then set the EnableViewState property of Textbox1 to False. Textbox2 is set to True. The button has no code in it - It simply has an...
11
by: Keith | last post by:
I apologize for those of you who think I'm posting on the same topic. It is not that I don't appreciate all of your comments - and I'm definitely reading them all - but I think I have a differing...
1
by: Anthony Nystrom | last post by:
I am trying to pass a text stream from streamwriter class to a richtextbox, or textbox doesn't matter which one. I have the file write version working fine such as: x.streamwriter =...
2
by: RSH | last post by:
Hi, i have a situation where I have a VB .Net Module built that contains all of the functions I need. I now need to add a form to the project and i need the form to sdisplay and the module code...
2
by: JohnR | last post by:
I have a question on bindingcontext, bindings, and controlbindingscollection. I understand the very basic idea, and I think I should be able to do this, but I'm not sure how. First problem: I...
20
by: tshad | last post by:
Using VS 2003, I am trying to take a class that I created to create new variable types to handle nulls and track changes to standard variable types. This is for use with database variables. This...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
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,...
0
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...
0
Oralloy
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,...
0
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...
0
tracyyun
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...
0
agi2029
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.