Solved

client side javascript for VB.net

Posted on 2013-06-04
6
295 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 M
Ron M 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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

705 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now