• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 316
  • Last Modified:

textbox attributes

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
razza_b
Asked:
razza_b
  • 8
  • 6
  • 2
  • +1
2 Solutions
 
Meir RivkinFull stack Software EngineerCommented:
what control is txtWTBaseSN?  is it .net control?
is it winform or web application?
0
 
razza_bAuthor Commented:
oh sorry its a vb.net 2005 control
0
 
Meir RivkinFull stack Software EngineerCommented:
can u post the whole code?
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
razza_bAuthor Commented:
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
 
Meir RivkinFull stack Software EngineerCommented:
this looks like textbox web control. can u verify this?
0
 
razza_bAuthor Commented:
yes its a web control
0
 
CodeCruiserCommented:
And you are trying to convert it to C# web code? Attributes only exists in web and not winforms.
0
 
razza_bAuthor Commented:
the vb code is being converted in C#.net 2010 web
0
 
Meir RivkinFull stack Software EngineerCommented:
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
 
razza_bAuthor Commented:
i dont have attributes available to select it does not contain a defition, is there a certain namespace i need ?
0
 
Meir RivkinFull stack Software EngineerCommented:
using System.Web.UI.WebControls;
0
 
razza_bAuthor Commented:
that will be why and this C# web app is silverlight and i dont see that namespace.
0
 
razza_bAuthor Commented:
do you know the alternative for this?
0
 
Meir RivkinFull stack Software EngineerCommented:
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
 
razza_bAuthor Commented:
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
 
CodeCruiserCommented:
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
 
ArkCommented:
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 8
  • 6
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now