Solved

textbox attributes

Posted on 2013-06-27
17
278 Views
Last Modified: 2013-08-08
Hi

Can someone tell me what these 2 lines of code do and what it would be like converted into C#? in c# there is no attributes.

txtWTBaseSN.Attributes.Item("Len").ToUpper()
txtWTBaseSN.Attributes.Item("Pre").ToUpper()
0
Comment
Question by:razza_b
  • 8
  • 6
  • 2
  • +1
17 Comments
 
LVL 42

Expert Comment

by:sedgwick
ID: 39280643
what control is txtWTBaseSN?  is it .net control?
is it winform or web application?
0
 
LVL 1

Author Comment

by:razza_b
ID: 39280651
oh sorry its a vb.net 2005 control
0
 
LVL 42

Expert Comment

by:sedgwick
ID: 39280662
can u post the whole code?
0
 
LVL 1

Author Comment

by:razza_b
ID: 39280696
here is a snippet...

If reader.HasRows Then
                reader.Read()

                If Not reader("PdWTBaseSN") Is DBNull.Value AndAlso CBool(reader("PdWTBaseSN")) Then

                    txtWTBaseSN.Attributes.Item("Len") = reader("PdWTBaseSNLength")
                    txtWTBaseSN.Attributes.Item("Pre") = reader("PdWTBaseSNPrefix")
                Else

                    txtWTBaseSN.Attributes.Item("Len") = ""
                    txtWTBaseSN.Attributes.Item("Pre") = ""
                End If
0
 
LVL 42

Expert Comment

by:sedgwick
ID: 39280700
this looks like textbox web control. can u verify this?
0
 
LVL 1

Author Comment

by:razza_b
ID: 39280708
yes its a web control
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 39280727
And you are trying to convert it to C# web code? Attributes only exists in web and not winforms.
0
 
LVL 1

Author Comment

by:razza_b
ID: 39280732
the vb code is being converted in C#.net 2010 web
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 42

Expert Comment

by:sedgwick
ID: 39280733
here in C#:
if (reader.HasRows) {
	reader.Read();

	if (Convert.IsDBNull(reader["PdWTBaseSN"]) && (bool)reader["PdWTBaseSN"]) {
		txtWTBaseSN.Attributes["Len"] = reader["PdWTBaseSNLength"];
		txtWTBaseSN.Attributes["Pre"] = reader["PdWTBaseSNPrefix"];

	} else {
		txtWTBaseSN.Attributes["Len"] = "";
		txtWTBaseSN.Attributes["Pre"] = "";
	}
}

Open in new window

0
 
LVL 1

Author Comment

by:razza_b
ID: 39280751
i dont have attributes available to select it does not contain a defition, is there a certain namespace i need ?
0
 
LVL 42

Expert Comment

by:sedgwick
ID: 39280759
using System.Web.UI.WebControls;
0
 
LVL 1

Author Comment

by:razza_b
ID: 39280771
that will be why and this C# web app is silverlight and i dont see that namespace.
0
 
LVL 1

Author Comment

by:razza_b
ID: 39280781
do you know the alternative for this?
0
 
LVL 42

Expert Comment

by:sedgwick
ID: 39280788
can u explain what do u want to achieve?
you have a silverlight app in vb.net and u want to convert to C#?
0
 
LVL 1

Author Comment

by:razza_b
ID: 39280805
i have vb.net 2005 code that is being converted into C# 2010 web (silverlight)  and i just want to know how to achieve the equivalent to the attributes
0
 
LVL 83

Assisted Solution

by:CodeCruiser
CodeCruiser earned 250 total points
ID: 39280814
That code is just adding two custom properties to the textbox class (Length and Prefix). These are probably being retrieved later in other parts of the code (when saving for example). I think you may be able to use Tag property of the textbox in silverlight to store this information but you will need to combine it into one piece of information (semicolon separate string for example or a structure).
0
 
LVL 27

Accepted Solution

by:
Ark earned 250 total points
ID: 39288750
These are probably being retrieved later in other parts of the code (when saving for example)
They are ALREADY saved in a DataTable - why not use it directly? Or assign DataRow to Tag property.
PS. 'Standard' html/asp textboxes doesn't have such attributes. But I can guess that "Pre" means preformatted and Len is length. Probably they r using somewhere in javascript to format div (or custom div-based control) output.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Please explain "Multi-Tenant Services" 5 60
Name space syntax error 12 39
Angular JS Route 3 44
Need a starter for ETL protocol? 4 31
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…

939 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

10 Experts available now in Live!

Get 1:1 Help Now