Solved

client side javascript for VB.net

Posted on 2013-06-04
6
300 Views
Last Modified: 2013-08-23
I have a custom textbox control which I need to be readonly, but i am having trouble posting back the page and retaining the value of the box in a web page.

I read that you could set the read-only via javascript on the client side which allows the values to repost and still gives the appearance of readonly.  I found the sample java code, but I am sure how to call that via the textbox control.  There is a onload option, would that be the best place?

I believe this control is basedon the text box control. HOw would you apply this javascript to the standard textbox control?
0
Comment
Question by:red_75116
6 Comments
 
LVL 11

Assisted Solution

by:MajorBigDeal
MajorBigDeal earned 250 total points
ID: 39220482
If you put the data in a hidden field, you can load it back into the control on the page load event.  Example: http://forums.asp.net/t/1428896.aspx/1

You could also actually add your updated info into the viewstate for the control so that .net would persist it for you but I don't recommend that approach.
0
 
LVL 25

Assisted Solution

by:Ron Malmstead
Ron Malmstead earned 125 total points
ID: 39220519
Why can't you just do ..

textbox1.enabled = false

?
0
 
LVL 18

Assisted Solution

by:Rajar Ahmed
Rajar Ahmed earned 125 total points
ID: 39220985
If u set by this,

//txtbox1.ReadOnly=false;

or in

//<asp:textbox readonly="false"

Just remove  those lines

Try by this,
txtbox1.Attributes.Add("readonly","readonly");

Open in new window

0
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 

Author Comment

by:red_75116
ID: 39253481
I still cannot get this to work.  My application uses a custom textbox called inputfield.  When I add the readonly= true to the below, the field is readonly, but when posting back to the page, the values are lost.

                <ex:InputField runat="server" ID="ifReceiver" Readonly="true" />


I was told if I could make the field be readonly with clientside script, it would appear read only and the postback would still work.

How do I call this javascript?
0
 
LVL 11

Accepted Solution

by:
MajorBigDeal earned 250 total points
ID: 39378282
Modifying the field in a client side script will not cause the change to be automatically posted back.  The way to accomplish this is to put the data you want to post back into a hidden field and then load it back to the control on the page load event.  Here is an example:  http://forums.asp.net/t/1428896.aspx/1

You could try to directly modify the viewstate on the client-side so that it would get posted back but that is difficult and error-prone.  Unfortunately, it is not a simple matter of just loading the data into the field on the client-side.
0
 

Author Closing Comment

by:red_75116
ID: 39433193
I was able to get the results I needed via the viewstate.  Thanks so much for the help
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question