What you want to see on DotNetFunda.com ?
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 3642 |  Welcome, Guest!   Register  Login
 Home > Code Snippets > ASP.NET > Set Multiple Textboxes inside the Panel to Readonly ...
Bugwee

Set Multiple Textboxes inside the Panel to Readonly

 Code Snippet posted by: Bugwee | Posted on: 5/6/2011 | Category: ASP.NET Codes | Views: 2441 | Status: [Member] | Points: 40 | Alert Moderator   


the panel on aspx page
 <asp:Panel ID="pnlBranch" runat="server">

<%-- your multiple textbox inside --%>
</asp:Panel>


to set multiple textbox to readonly
Protected Sub SetReadOnlyTrue()

For Each ctrl As Control In pnlBranch.Controls
If TypeOf ctrl Is TextBox Then
CType(ctrl, TextBox).ReadOnly = True
End If
Next
End Sub

Found interesting? Add this to:


 Responses

Akiii
Posted by: Akiii | Posted on: 5/24/2011 | Level: Bronze | Status: [Member] | Points: 10 | Alert Moderator 

Hi bugwee.....

Can you convert this code in C#.....please?

Thanks and Regards
Akiii

Bugwee
Posted by: Bugwee | Posted on: 5/25/2011 | Level: Starter | Status: [Member] | Points: 10 | Alert Moderator 

hello Akiii,

Here's the code using c#.. Hope this may help..

protected void SetReadOnlyTrue()

{

foreach (Control ctrl in pnlBranch.Controls)
{

if (ctrl is TextBox)
{
((TextBox)ctrl).ReadOnly = true;

}

}

}


Regards,
Bugwee

Akiii
Posted by: Akiii | Posted on: 5/25/2011 | Level: Bronze | Status: [Member] | Points: 10 | Alert Moderator 

Hi bugwee.....

Thanks friend........your code is working absolutely fine.....

But can you tell me on what occasions a text-box should be made read-only......?
Text boxes are used for writing texts ......right ?

Thanks and Regards
Akiii

Bugwee
Posted by: Bugwee | Posted on: 5/25/2011 | Level: Starter | Status: [Member] | Points: 10 | Alert Moderator 

Hello Akiii,

Mostly my projects are e.g. data entries or POS. Therefore, i have to set it to read-only when the users just want to view their previous entries.

Regards,
Bugwee

Akiii
Posted by: Akiii | Posted on: 5/25/2011 | Level: Bronze | Status: [Member] | Points: 10 | Alert Moderator 

hi bugwee.....

Okay, but in what other scenarios we may use text box as readonly...?

Regards
Akiii

Bugwee
Posted by: Bugwee | Posted on: 5/25/2011 | Level: Starter | Status: [Member] | Points: 10 | Alert Moderator 

Hello Akiii,

We may set the textbox to readonly to prevent a malicious user from changing a Text value that is read-only.

Regards,
Bugwee

Akiii
Posted by: Akiii | Posted on: 5/25/2011 | Level: Bronze | Status: [Member] | Points: 10 | Alert Moderator 

hi bugwee....

okay.....thanks for the info.....and the code....
keep posting.....

Regards
Akiii

>> Write Response - Respond to this post and get points

More codes snippets

About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/25/2013 1:59:44 PM