Make it non-editable

Hi,
I want to make the following two items

            <li>
                <div class="imagesList-item-frame shadow">
                    ...
                    <div class="legend">
                        ...
                        <input type="textbox" id="tb_p1_prt" style="height:20px; width:116px; border:inherit; background-color:#F0FAF9;" runat="server" /><br/><br/>
                        <input type="button" id="butt_p1" onclick="openPopup();" style="height:23px; width:97px" runat="server" />
                    </div>
                </div>
            </li>
            ....
                        Button butt = this.FindControl("butt_p1") as Button;
                        HtmlInputControl tb_p0_prt = (HtmlInputControl) this.FindControl("tb_p1_prt");
                        ...

Open in new window

non-editable, upon some given conditions. how?
LVL 11
HuaMin ChenProblem resolverAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

leakim971PluritechnicianCommented:
Test page : http://jsfiddle.net/21q5dojj/1/
document.getElementById("<%= tb_p1_prt.ClientID %>").setAttribute("readOnly", true);

Open in new window

0
HuaMin ChenProblem resolverAuthor Commented:
Thanks. I only want to do this, upon some given conditions, preferably from code-behind event. How?
0
leakim971PluritechnicianCommented:
so use a asp:TextBox  and set the ReadOnly attribute
or if you still want to use the input and use the client script manager :
http://msdn.microsoft.com/library/system.web.ui.clientscriptmanager(v=vs.110).aspx
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

HuaMin ChenProblem resolverAuthor Commented:
Yes, I have to declare as "input type" and can I have more details to make it non-editable, using ClientScriptManager?
0
leakim971PluritechnicianCommented:
check the example on the msdn link, let me know if you don't understand something
0
HuaMin ChenProblem resolverAuthor Commented:
I don't see the detailed step to make the item non-editable, from the url.
0
leakim971PluritechnicianCommented:
the non-editable step is on my first post.
you just need to combine both
0
HuaMin ChenProblem resolverAuthor Commented:
Sorry, that should be done through javascript function, right? How about that I want to do that within code-behind event?
0
leakim971PluritechnicianCommented:
      cstext2.Append("<script type=\"text/javascript\">");
      cstext2.Append("window.onload = function() { document.getElementById('" + tb_p1_prt.ClientID +"').setAttribute(\"readOnly\", true); }");
      cstext2.Append("</script>");

Open in new window

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.