[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

client side javascript for VB.net

Posted on 2013-06-04
6
Medium Priority
?
310 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 1000 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 500 total points
ID: 39220519
Why can't you just do ..

textbox1.enabled = false

?
0
 
LVL 18

Assisted Solution

by:Rajar Ahmed
Rajar Ahmed earned 500 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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 1000 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
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.…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses
Course of the Month17 days, 15 hours left to enroll

831 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