Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Question on textbox property.

Reply
Thread Tools

Question on textbox property.

 
 
=?Utf-8?B?SGVucnk=?=
Guest
Posts: n/a
 
      12-29-2004
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

 
Reply With Quote
 
 
 
 
bruce barker
Guest
Posts: n/a
 
      12-29-2004
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" <> wrote in message
news:814EB9E4-3C76-4A9F-9CD6-...
| 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
|


 
Reply With Quote
 
 
 
 
Steve Lutz
Guest
Posts: n/a
 
      12-30-2004
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" <> wrote in message
news:814EB9E4-3C76-4A9F-9CD6-...
> 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
>



 
Reply With Quote
 
=?Utf-8?B?SGVucnk=?=
Guest
Posts: n/a
 
      12-30-2004

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" <> wrote in message
> news:814EB9E4-3C76-4A9F-9CD6-...
> | 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
> |
>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Rich TextBox / HTML TextBox Jay ASP .Net 5 04-28-2005 11:15 PM
Calendar popup - using ASP textbox instead of HTML textbox =?Utf-8?B?Q2hyaXM=?= ASP .Net 3 03-30-2005 06:02 PM
runat="server"....a simple html textbox or a webform server textbox...that is the question. Hazzard ASP .Net 2 07-23-2003 07:32 AM
Re: runat="server"....a simple html textbox or a webform server textbox...that is the question. Natty Gur ASP .Net 0 07-22-2003 03:57 AM
Re: VERY STRANGE BUG? Adding a textbox control causes other textbox control to fail??? S. Justin Gengo ASP .Net 0 07-16-2003 06:51 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57