Showing posts with label writing. Show all posts
Showing posts with label writing. Show all posts

Wednesday, March 28, 2012

Trouble binding a dropdown list in a detailsview.

Ok, I'm lost. I'm writing a webpage in VB/Dot Net 2.0 and I'm trying to put
a
dropdown list in a detailsview. The dropdownlist is supposed to display a
simple enum.
From what little I've seen so far, the place in VB code to bind a ddl is in
the detailview's databound event. Any earlier and you can't get a handle on
the ddl. The detailsview is essentially alone on it's page and is called in
either edit or insert mode only. (In the page lode, I examine a querystring
parameter and based on that, set the detailsview to either edit or insert
mode.) I have created template ddls in the column corresponding to this
variable. All existing records have valid values in this field (a smallint)
.
The code itself is routine:
ddlClassType = DetailsView1.FindControl("ddlClassType")
Dim names() As String = System.Enum.GetNames(GetType(ClassType))
Dim values() As Integer = System.Enum.GetValues(GetType(ClassType))
Dim i As Integer
For i = 0 To names.Length - 1
Dim item As New ListItem(names(i), values(i).ToString)
ddlClassType.Items.Add(item)
Next
This works fine for Inserts but the code never gets to this point for
updates. It crashes with the error: 'ddlClassType' has a SelectedValue whic
h
is invalid because it does not exist in the list of items. Parameter name:
value
Any suggestions?Howdy,
Moving population code into detail's DataBinding event should resolve the
problem. Take a look at your aspx code and notice, there's Bind or Eval
statement inside SelectedValue: SelectedValue='<%# Eval("WhatEver") %>' whic
h
expects items have already been populated. Unfortunatelly, you're populating
items afterwards, hence the exception.
hope this helps
--
Milosz
"B. Chernick" wrote:

> Ok, I'm lost. I'm writing a webpage in VB/Dot Net 2.0 and I'm trying to pu
t a
> dropdown list in a detailsview. The dropdownlist is supposed to display a
> simple enum.
> From what little I've seen so far, the place in VB code to bind a ddl is i
n
> the detailview's databound event. Any earlier and you can't get a handle
on
> the ddl. The detailsview is essentially alone on it's page and is called
in
> either edit or insert mode only. (In the page lode, I examine a querystrin
g
> parameter and based on that, set the detailsview to either edit or insert
> mode.) I have created template ddls in the column corresponding to this
> variable. All existing records have valid values in this field (a smallin
t).
>
> The code itself is routine:
> ddlClassType = DetailsView1.FindControl("ddlClassType")
> Dim names() As String = System.Enum.GetNames(GetType(ClassType))
> Dim values() As Integer = System.Enum.GetValues(GetType(ClassType))
> Dim i As Integer
> For i = 0 To names.Length - 1
> Dim item As New ListItem(names(i), values(i).ToString)
> ddlClassType.Items.Add(item)
> Next
> This works fine for Inserts but the code never gets to this point for
> updates. It crashes with the error: 'ddlClassType' has a SelectedValue wh
ich
> is invalid because it does not exist in the list of items. Parameter name:
> value
> Any suggestions?
>
Sorry, actually no. If I move the code into the DetailView's DataBinding
event (or the screen's), the code fails entirely because it can't find the
ddl. Hasn't been rendered yet.
I have a vague memory of populating a dropdown in my last job using
javascript and those <%# %> brackets, but I'm still digging through my notes
for that one. Have you ever done that?
"Milosz Skalecki [MCAD]" wrote:
> Howdy,
> Moving population code into detail's DataBinding event should resolve the
> problem. Take a look at your aspx code and notice, there's Bind or Eval
> statement inside SelectedValue: SelectedValue='<%# Eval("WhatEver") %>' wh
ich
> expects items have already been populated. Unfortunatelly, you're populati
ng
> items afterwards, hence the exception.
> hope this helps
> --
> Milosz
>
> "B. Chernick" wrote:
>
Many times. Paste the code.
--
Milosz
"B. Chernick" wrote:
> Sorry, actually no. If I move the code into the DetailView's DataBinding
> event (or the screen's), the code fails entirely because it can't find the
> ddl. Hasn't been rendered yet.
> I have a vague memory of populating a dropdown in my last job using
> javascript and those <%# %> brackets, but I'm still digging through my not
es
> for that one. Have you ever done that?
> "Milosz Skalecki [MCAD]" wrote:
>
Hi
On 17 Nov, 01:37, B. Chernick wrote:
> Sorry, actually no. If I move the code into the DetailView's DataBinding
> event (or the screen's), the code fails entirely because it can't find the
> ddl. Hasn't been rendered yet.
Milosz is right about the timing of the code causing the exception. In
insert mode, there is no attempt to automatically bind the selected
value of the ddl control to a field value because it's a new record,
whereas in Edit mode it tries to bind the selected value to the
current value of the field.
To get round this you'll have to delete the databinding between the
ddl and the datasource (in the edit mode template) and set the
selected value manually in code immediately after the code you have
already written. In the DataBound event, you can differentiate
betweeen the two modes using DetailsView1.CurrentMode() and make the
code for setting the ddl selected value conditonal upon that.
You'll also need to handle the update manually for the respective
datafield as well in the Updating event.
HTH
Thank you Milosz and Phil.
Out of town for the holiday but I continue this as soon as I get home Friday
.
"Phil H" wrote:

> Hi
> On 17 Nov, 01:37, B. Chernick wrote:
> Milosz is right about the timing of the code causing the exception. In
> insert mode, there is no attempt to automatically bind the selected
> value of the ddl control to a field value because it's a new record,
> whereas in Edit mode it tries to bind the selected value to the
> current value of the field.
> To get round this you'll have to delete the databinding between the
> ddl and the datasource (in the edit mode template) and set the
> selected value manually in code immediately after the code you have
> already written. In the DataBound event, you can differentiate
> betweeen the two modes using DetailsView1.CurrentMode() and make the
> code for setting the ddl selected value conditonal upon that.
> You'll also need to handle the update manually for the respective
> datafield as well in the Updating event.
> HTH
>
After some trial and error, I finally got it to work. Is this roughly what
you had in mind? (I first replaced the ddl in the edit template with a new
unbound dropdownlist.)
Private Sub DetailsView1_DataBound(ByVal sender As Object, ByVal e As
System.EventArgs) Handles DetailsView1.DataBound
Dim names() As String = System.Enum.GetNames(GetType(ClassType))
Dim values() As Integer = System.Enum.GetValues(GetType(ClassType))
If DetailsView1.CurrentMode = DetailsViewMode.Edit Then
ddlClassType = DetailsView1.FindControl("ddlClassType")
Dim i As Integer
For i = 0 To names.Length - 1
Dim item As New ListItem(names(i), values(i).ToString)
ddlClassType.Items.Add(item)
Next
' Set incoming value
Dim dr As DataRowView
dr = DetailsView1.DataItem
ddlClassType.SelectedValue = dr.Item("ClassType").ToString
End If
End Sub
Private Sub ObjectDataSource1_Updating(ByVal sender As Object, ByVal e
As System.Web.UI.WebControls.ObjectDataSourceMethodEventArgs) Handles
ObjectDataSource1.Updating
' manually update values here
ddlClassType = DetailsView1.FindControl("ddlClassType")
e.InputParameters.Item("ClassType") = ddlClassType.SelectedValue
End Sub
"Phil H" wrote:

> Hi
> On 17 Nov, 01:37, B. Chernick wrote:
> Milosz is right about the timing of the code causing the exception. In
> insert mode, there is no attempt to automatically bind the selected
> value of the ddl control to a field value because it's a new record,
> whereas in Edit mode it tries to bind the selected value to the
> current value of the field.
> To get round this you'll have to delete the databinding between the
> ddl and the datasource (in the edit mode template) and set the
> selected value manually in code immediately after the code you have
> already written. In the DataBound event, you can differentiate
> betweeen the two modes using DetailsView1.CurrentMode() and make the
> code for setting the ddl selected value conditonal upon that.
> You'll also need to handle the update manually for the respective
> datafield as well in the Updating event.
> HTH
>

Trouble connecting to AS/400 with ASP.NET

Hello,

I am writing an ASP.NET application and trying to connect to an as400
using an ADODB connection. I recently completed a Windows application
that connects to the 400. My code works in the Windows world, so
theoretically, it should work for the ASP application as well. But it
doesn't. I keep getting the error CWBSY1006 - User ID is Invalid. I'm
using my Windows login information to automatically log into the 400,
so a userid and password is not required. It does work, however, if I
hard code my userid and password into the connection string. The
only problem with that is that the users need to log in with their
information for security purposes. Here is my code. Any ideas would
be greatly appreciated.

Thanks,
Amaryllis

AS400.Define("MyAS400")
AS400.Connect(cwbx.cwbcoServiceEnum.cwbcoServiceDa taQueues)
conn400 = New ADODB.Connection
conn400.ConnectionString = "Provider=IBMDA400.DataSource.1;" & _
"Data source=MyAS400"
conn400.Open()That is because ASP.NET runs under the ASPNET account. It does not run
under you. So of course, the ASPNET account does not have integrated
security access to your database.

You neither need to give that account rights to the database, or use a
username/password to log in.

"Amaryllis" <amy_hankins@.swn-dot-com.no-spam.invalid> wrote in message
news:410fe1bf$1_5@.Usenet.com...
> Hello,
> I am writing an ASP.NET application and trying to connect to an as400
> using an ADODB connection. I recently completed a Windows application
> that connects to the 400. My code works in the Windows world, so
> theoretically, it should work for the ASP application as well. But it
> doesn't. I keep getting the error CWBSY1006 - User ID is Invalid. I'm
> using my Windows login information to automatically log into the 400,
> so a userid and password is not required. It does work, however, if I
> hard code my userid and password into the connection string. The
> only problem with that is that the users need to log in with their
> information for security purposes. Here is my code. Any ideas would
> be greatly appreciated.
> Thanks,
> Amaryllis
> AS400.Define("MyAS400")
> AS400.Connect(cwbx.cwbcoServiceEnum.cwbcoServiceDa taQueues)
> conn400 = New ADODB.Connection
> conn400.ConnectionString = "Provider=IBMDA400.DataSource.1;" & _
> "Data source=MyAS400"
> conn400.Open()
I agree, but when you add <impersonate=TRUE /> to the web.config
file, it should pick up your information and use it rather than the
ASPNET account information. I've always been able to connect to SQL
Server using that approach. I'm just not sure what is different
about DB2 on the AS/400.

Amaryllis

Trouble connecting to AS/400 with ASP.NET

Hello,
I am writing an ASP.NET application and trying to connect to an as400
using an ADODB connection. I recently completed a Windows application
that connects to the 400. My code works in the Windows world, so
theoretically, it should work for the ASP application as well. But it
doesn't. I keep getting the error CWBSY1006 - User ID is Invalid. I'm
using my Windows login information to automatically log into the 400,
so a userid and password is not required. It does work, however, if I
hard code my userid and password into the connection string. The
only problem with that is that the users need to log in with their
information for security purposes. Here is my code. Any ideas would
be greatly appreciated.
Thanks,
Amaryllis
AS400.Define("MyAS400")
AS400.Connect(cwbx.cwbcoServiceEnum.cwbcoServiceDataQueues)
conn400 = New ADODB.Connection
conn400.ConnectionString = "Provider=IBMDA400.DataSource.1;" & _
"Data source=MyAS400"
conn400.Open()That is because ASP.NET runs under the ASPNET account. It does not run
under you. So of course, the ASPNET account does not have integrated
security access to your database.
You neither need to give that account rights to the database, or use a
username/password to log in.
"Amaryllis" <amy_hankins@.swn-dot-com.no-spam.invalid> wrote in message
news:410fe1bf$1_5@.mcse.ms...
> Hello,
> I am writing an ASP.NET application and trying to connect to an as400
> using an ADODB connection. I recently completed a Windows application
> that connects to the 400. My code works in the Windows world, so
> theoretically, it should work for the ASP application as well. But it
> doesn't. I keep getting the error CWBSY1006 - User ID is Invalid. I'm
> using my Windows login information to automatically log into the 400,
> so a userid and password is not required. It does work, however, if I
> hard code my userid and password into the connection string. The
> only problem with that is that the users need to log in with their
> information for security purposes. Here is my code. Any ideas would
> be greatly appreciated.
> Thanks,
> Amaryllis
> AS400.Define("MyAS400")
> AS400.Connect(cwbx.cwbcoServiceEnum.cwbcoServiceDataQueues)
> conn400 = New ADODB.Connection
> conn400.ConnectionString = "Provider=IBMDA400.DataSource.1;" & _
> "Data source=MyAS400"
> conn400.Open()
>
I agree, but when you add <impersonate=TRUE /> to the web.config
file, it should pick up your information and use it rather than the
ASPNET account information. I've always been able to connect to SQL
Server using that approach. I'm just not sure what is different
about DB2 on the AS/400.
Amaryllis

Thursday, March 22, 2012

Trouble with Multiple Master Pages in ASP.NET 2.0

I am writing an ASP.NET 2.0 application that uses more than one master page.
Currently, there are two pages, Freedom1.master and Freedom2.master. I have
no problems with Freedom1.master. However, I am having problems with
Freedom2.master.
The first problem is I sometimes get the following error when I build the
site.
The type 'Freedom2' exists in both
'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET
Files\freedomlincwebsite\ae6160cc\fecd2e
a4\App_Web_ammoxc8r.dll' and
'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET
Files\freedomlincwebsite\ae6160cc\fecd2e
a4\App_Web_fxnhzrev.dll'
The error appears for each page built using Freedom2.master.
The second problem occurs at runtime for statments like the following.
protected void Page_Load(object sender, EventArgs e)
{
Freedom2 master = (Freedom2)Master;
master.Page.Header.Title = "Freedom LINC Registration";Your code looks a bit confusing, you seem to be declaring an object called
master of type freedom2 and initialising it with the value contained in it's
self cast as a type freedom2. What are trying to do with that code?
"EagleRed@.HighFlyingBirds.com" wrote:

> I am writing an ASP.NET 2.0 application that uses more than one master pag
e.
> Currently, there are two pages, Freedom1.master and Freedom2.master. I ha
ve
> no problems with Freedom1.master. However, I am having problems with
> Freedom2.master.
> The first problem is I sometimes get the following error when I build the
> site.
> The type 'Freedom2' exists in both
> 'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET
> Files\freedomlincwebsite\ae6160cc\fecd2e
a4\App_Web_ammoxc8r.dll' and
> 'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET
> Files\freedomlincwebsite\ae6160cc\fecd2e
a4\App_Web_fxnhzrev.dll'
> The error appears for each page built using Freedom2.master.
> The second problem occurs at runtime for statments like the following.
> protected void Page_Load(object sender, EventArgs e)
> {
> Freedom2 master = (Freedom2)Master;
> master.Page.Header.Title = "Freedom LINC Registration";
> .
> .
> .
> The error message states that there is a failure to cast an infinite integ
er
> to the type, Freedom2.
> What is going on? How do I address these issues? These problems are
> intermittent but significant.
> Any input is appreciated.
> Thank you,
> EagleRed
>
>
In article <31042077-F0EC-49B9-90D7-C782AEAE5187@.microsoft.com>,
"EagleRed@.HighFlyingBirds.com"
<EagleRedHighFlyingBirdscom@.discussions.microsoft.com> writes
>I am writing an ASP.NET 2.0 application that uses more than one master page
.
>Currently, there are two pages, Freedom1.master and Freedom2.master. I hav
e
>no problems with Freedom1.master. However, I am having problems with
>Freedom2.master.
>The first problem is I sometimes get the following error when I build the
>site.
>The type 'Freedom2' exists in both
>'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET
> Files\freedomlincwebsite\ae6160cc\fecd2e
a4\App_Web_ammoxc8r.dll' and
>'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET
> Files\freedomlincwebsite\ae6160cc\fecd2e
a4\App_Web_fxnhzrev.dll'
>The error appears for each page built using Freedom2.master.
Try stopping the server, then deleting the files in the temporary
ASP.NET files folder. Then restart the server and try again. I have seen
this cure this problem.

>The second problem occurs at runtime for statments like the following.
> protected void Page_Load(object sender, EventArgs e)
> {
> Freedom2 master = (Freedom2)Master;
> master.Page.Header.Title = "Freedom LINC Registration";
<snip>
Why are you doing it this way? Title is a standard property of the page,
even when master pages are used, so you can simply do...
Page.Header.Title = "Freedom LINC Registration";
More to the point, if you are setting the title to a fixed string, just
set it in the Page directive of the .aspx file instead of in code. As I
understand it, this gets compiled with the page, so will be a teensy
weensy bit faster too.
HTH
Alan Silver
(anything added below this line is nothing to do with me)
Needed or non needed code I have the same problem:
I usually cast master in order to hide or show some components / parts
of page. Anyhow why I want to cast master page is not an issue here.
The issue is why this cast may or may not fail.
My findings are that:
- I assume that in place compilation creates 2 copies of assembly,
- killing w3wp usually helps (if it doesn't delete asp.net tmp
folders/files),
- it may happens only after some compilation was made (after changes in
files, etc...).
I belive that, precompiled deployment is safer regarding this
problem...
I would like some more info about that problem.
bye,
D

Trouble with Multiple Master Pages in ASP.NET 2.0

I am writing an ASP.NET 2.0 application that uses more than one master page.
Currently, there are two pages, Freedom1.master and Freedom2.master. I have
no problems with Freedom1.master. However, I am having problems with
Freedom2.master.

The first problem is I sometimes get the following error when I build the
site.

The type 'Freedom2' exists in both
'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Tem porary ASP.NET
Files\freedomlincwebsite\ae6160cc\fecd2ea4\App_Web _ammoxc8r.dll' and
'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Tem porary ASP.NET
Files\freedomlincwebsite\ae6160cc\fecd2ea4\App_Web _fxnhzrev.dll'

The error appears for each page built using Freedom2.master.

The second problem occurs at runtime for statments like the following.

protected void Page_Load(object sender, EventArgs e)
{

Freedom2 master = (Freedom2)Master;
master.Page.Header.Title = "Freedom LINC Registration";Your code looks a bit confusing, you seem to be declaring an object called
master of type freedom2 and initialising it with the value contained in it's
self cast as a type freedom2. What are trying to do with that code?

"EagleRed@.HighFlyingBirds.com" wrote:

> I am writing an ASP.NET 2.0 application that uses more than one master page.
> Currently, there are two pages, Freedom1.master and Freedom2.master. I have
> no problems with Freedom1.master. However, I am having problems with
> Freedom2.master.
> The first problem is I sometimes get the following error when I build the
> site.
> The type 'Freedom2' exists in both
> 'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Tem porary ASP.NET
> Files\freedomlincwebsite\ae6160cc\fecd2ea4\App_Web _ammoxc8r.dll' and
> 'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Tem porary ASP.NET
> Files\freedomlincwebsite\ae6160cc\fecd2ea4\App_Web _fxnhzrev.dll'
> The error appears for each page built using Freedom2.master.
> The second problem occurs at runtime for statments like the following.
> protected void Page_Load(object sender, EventArgs e)
> {
> Freedom2 master = (Freedom2)Master;
> master.Page.Header.Title = "Freedom LINC Registration";
> .
> .
> .
> The error message states that there is a failure to cast an infinite integer
> to the type, Freedom2.
> What is going on? How do I address these issues? These problems are
> intermittent but significant.
> Any input is appreciated.
> Thank you,
> EagleRed
>
In this case I am changing the title of the page with the statement,

master.Page.Header.Title = "Freedom LINC Registration";

There are other occasions I wish to access properties on the master page
from the aspx page that uses it. For example to change the href on a link.

My problem is that I have multiple master pages, e.g. Freedom1. All inherit
from the Master class. Freedom1 derived pages work fine but I am getting
intermittent compilation or runtime errors with Freedom2.

Thanks,
EagleRed

"EagleRed@.HighFlyingBirds.com" wrote:

> I am writing an ASP.NET 2.0 application that uses more than one master page.
> Currently, there are two pages, Freedom1.master and Freedom2.master. I have
> no problems with Freedom1.master. However, I am having problems with
> Freedom2.master.
> The first problem is I sometimes get the following error when I build the
> site.
> The type 'Freedom2' exists in both
> 'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Tem porary ASP.NET
> Files\freedomlincwebsite\ae6160cc\fecd2ea4\App_Web _ammoxc8r.dll' and
> 'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Tem porary ASP.NET
> Files\freedomlincwebsite\ae6160cc\fecd2ea4\App_Web _fxnhzrev.dll'
> The error appears for each page built using Freedom2.master.
> The second problem occurs at runtime for statments like the following.
> protected void Page_Load(object sender, EventArgs e)
> {
> Freedom2 master = (Freedom2)Master;
> master.Page.Header.Title = "Freedom LINC Registration";
> .
> .
> .
> The error message states that there is a failure to cast an infinite integer
> to the type, Freedom2.
> What is going on? How do I address these issues? These problems are
> intermittent but significant.
> Any input is appreciated.
> Thank you,
> EagleRed
>
In article <31042077-F0EC-49B9-90D7-C782AEAE5187@.microsoft.com>,
"EagleRed@.HighFlyingBirds.com"
<EagleRedHighFlyingBirdscom@.discussions.microsoft.c om> writes
>I am writing an ASP.NET 2.0 application that uses more than one master page.
>Currently, there are two pages, Freedom1.master and Freedom2.master. I have
>no problems with Freedom1.master. However, I am having problems with
>Freedom2.master.
>The first problem is I sometimes get the following error when I build the
>site.
>The type 'Freedom2' exists in both
>'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Tem porary ASP.NET
>Files\freedomlincwebsite\ae6160cc\fecd2ea4\App_Web _ammoxc8r.dll' and
>'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Tem porary ASP.NET
>Files\freedomlincwebsite\ae6160cc\fecd2ea4\App_Web _fxnhzrev.dll'
>The error appears for each page built using Freedom2.master.

Try stopping the server, then deleting the files in the temporary
ASP.NET files folder. Then restart the server and try again. I have seen
this cure this problem.

>The second problem occurs at runtime for statments like the following.
> protected void Page_Load(object sender, EventArgs e)
> {
> Freedom2 master = (Freedom2)Master;
> master.Page.Header.Title = "Freedom LINC Registration";
<snip
Why are you doing it this way? Title is a standard property of the page,
even when master pages are used, so you can simply do...

Page.Header.Title = "Freedom LINC Registration";

More to the point, if you are setting the title to a fixed string, just
set it in the Page directive of the .aspx file instead of in code. As I
understand it, this gets compiled with the page, so will be a teensy
weensy bit faster too.

HTH

--
Alan Silver
(anything added below this line is nothing to do with me)
Needed or non needed code I have the same problem:

I usually cast master in order to hide or show some components / parts
of page. Anyhow why I want to cast master page is not an issue here.
The issue is why this cast may or may not fail.
My findings are that:
- I assume that in place compilation creates 2 copies of assembly,
- killing w3wp usually helps (if it doesn't delete asp.net tmp
folders/files),
- it may happens only after some compilation was made (after changes in
files, etc...).

I belive that, precompiled deployment is safer regarding this
problem...

I would like some more info about that problem.

bye,
D

Tuesday, March 13, 2012

Troubles displaying a changing read-only value

I am writing a form with one value being a total of a couple other values from my page. I put this in a read-only textbox so it can't be changed, and when I change the other boxes values, the JavaScript automatically changes this value. However, when I generate the e-mail I use textboxTotalSpace.text to make it appear in my email, but this will only display the original value, and not the new one.

Does anyone know how I fix this?

Thanks.

TextBox server control will not pick up the changed values (during LoadPostData()) if the textbox is set to read only. Check this link for a fix:

http://aspadvice.com/blogs/joteke/archive/2006/04/12/16409.aspx

Hope this helps,

Vivek


Thanks Vivek, but I am unsure where I am supposed to add theTextBox1.Attributes.Add("readonly","readonly")


That should go in the Page_Load event.

protected void Page_Load(object sender, EventArgs e)
{
// add the javascript attributes
TextBox1.Attributes.Add("readonly", "readonly");
}

Thanks


Because you are changing data at client side using java script....


You can put this in the Page Load method.


suresh modiya:

Because you are changing data at client side using java script....

Changed text box value client side WILL show up in the server code behind because textbox implements IPostBackDataHandler interface and it loads its value from the forms POST data in the LoadPostBackData() method.

Its only when it is set to readonly that this data load will not work on postback, hence the alternative.

Vivek