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

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 123
  • Last Modified:

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?
0
HuaMinChen
Asked:
HuaMinChen
  • 5
  • 4
1 Solution
 
leakim971PluritechnicianCommented:
Test page : http://jsfiddle.net/21q5dojj/1/
document.getElementById("<%= tb_p1_prt.ClientID %>").setAttribute("readOnly", true);

Open in new window

0
 
HuaMinChenBusiness AnalystAuthor 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
Get quick recovery of individual SharePoint items

Free tool – Veeam Explorer for Microsoft SharePoint, enables fast, easy restores of SharePoint sites, documents, libraries and lists — all with no agents to manage and no additional licenses to buy.

 
HuaMinChenBusiness AnalystAuthor 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
 
HuaMinChenBusiness AnalystAuthor 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
 
HuaMinChenBusiness AnalystAuthor 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

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now