|
My question has a reason.
I have a class with a function named Get_OneRecord.
The function Get_OneRecord gets ONLY ONE record from a database using a Data Reader.
The record has 4 fields. So this function returns a string collection with the four fields.
Should I use 4 properties as follows:
Public ReadOnly Property Name() As String
Get
Return Get_OneRecord{1}
End Get
End Property
Public ReadOnly Property Address() As String
Get
Return Get_OneRecord{2}
End Get
End Property
Which will return the first field of the collection or array: MyLabel.Text = MyClass.Name ...
Or should I use the function and access each string collection item outside: MyLabel.Text = Get_OneRecord{1}
Do you understand my problem?
Thanks,
Miguel
|
|
|
|
|
Use properties, as they give a name to the values. "Name" is much more descriptive than "1".
Don't read the record from the database each time you use a property, though. Read the record the first time it's needed, and store the data in a private variable in the class.
Class
Private Data() as String
Public ReadOnly Property Name() As String
Get
If Data is Nothing Then Data = Get_OneRecord()
Return Data(0)
End Get
End Property
...
Private Sub Get_OneRecord() as String()
...
End Sub
End Class
---
b { font-weight: normal; }
|
|
|
|
|
Generally properties are used to get and set values, and methods are used when you perform some work.
As you are just getting a simple value, it would be logical to use a property.
If you did some more complicated work to get the value, like reading it from a file, it would be more logical to use a method.
In some cases properties can do a bit more work, but then there is a difference in how you expect properties and methods to handle the data. A property can for example read a value from file and keep the value in a private variable, so that it doesn't have to read the file if you read from the property again. If you have a method on the other hand, you would rather expect it to actually read the value from file each time you use it.
---
b { font-weight: normal; }
|
|
|
|
|
|
check this
http://www.codeproject.com/aspnet/PicManager.asp?df=100&forumid=156404&exp=0&select=1465072
|
|
|
|
|
Hi all! Pls help me with using spell checking capabilities of Ms-Word in asp.net.
Thanks.
|
|
|
|
|
Hi Friends,
I am filling treeview from sqlserver table, its working and I am happy.
But My problem is
I want to use SiteMapPath tool with that treeview but I dont know how? I tried to search over internet but couldn't find any good stuff.
I am not sure if i can use SiteMapPath tool in the above stated secnario. If I can use then please help or if you know any other method to provide SiteMapPath functionality, It would be a great help.
thanks in advance.
Naveed Kamboh
|
|
|
|
|
Hi,
You can use the the tree view's NavigateUrl property to navigate to different links. However, i gues for site map path we need to use the web.Sitemap file and add all the nodes.
|
|
|
|
|
Hello.
If i have some user errors I want to return to the client, what is best way to do it?
Example:
I have a WS:
[WebMethod]
public boolean addUser(struct userDetails)
In this registration I validate that the:
-phonenumber is in a valid format
-email is in a valid format
If these two validations fail I want to return the error message to the user.
What is the smoothest way to perform this ?
Regards,
Markus Foss, Oslo, Norway
|
|
|
|
|
Hi Folks! I have a button clicking on which some processing is done, what I want to do is show a message "Processing" until results are displayed. Similarly when Google page is loading it shows "Loading".i.e How to show loading message when page is loading. How to achieve this.Any idea?
Thanks
|
|
|
|
|
you have to use ajax/atlas for that.
|
|
|
|
|
Pls guide me to a good Ajax/Atlas tutorial from where I can start.
Thanks.
|
|
|
|
|
HI
i have an image stored with only solid colors
i want to know color percentage of each color in the image
can u help me how to do it
piyush
|
|
|
|
|
|
Hi ...
- Import the System.Drawing.Bitmap
- Declare a new bitmap image: Dim pic As New Bitmap(filename)
- Now use the pic.getpixel(x,y) method to get the A,R,G,B numbers in the image ... x & y r the coordinates
for i = 0 to pic.width - 1
for j = 0 to pic.height - 2
c = pic.getpixel(x,y) 'c is a color
next
next
- You can declare and array of colors and increment its index for color repitition in the loop the divide the total color occurances by the total colors in the image
Hope It's useful ... And if u need anything else in this field don't hesitate to ask me
Best Regards
3ala2
|
|
|
|
|
Dear all,
Pls tell me how to retrive OLE Object from msaccess.
|
|
|
|
|
I have my project uploaded on an open ip. my project uses ajax and added reference in web.config. there is also other project in .net. these projects take my web. config as their web.config. and throws error that ajax.dll not found. i have to remove this http handler from web.config. but my ajax works.
plz help me to find the solution.
Thanks For ur help
|
|
|
|
|
Hi,
I am using the following code in codebehind file for creating a saveAs dialog box in webApplication in VB.net.
Dim filename As String = Session("DateTimeStampZip")
Dim fullPath As String = Server.MapPath(ConfigurationSettings.AppSettings("ServerDownload")) & "\" & filename
Dim dataStream As FileStream = New FileStream(fullPath,System.IO.FileMode.Open)
Dim fileLength As Integer = System.Convert.ToInt32(dataStream.Length)
dataStream.Close()
dataStream = Nothing
Response.Clear()
Response.ContentType = "application/octet-stream"
Response.AppendHeader("Content-Disposition", "attachment; filename=" & filename)
Response.AppendHeader("Content-length", fileLength.ToString())
Response.WriteFile(fullPath)
Response.End
My problem is that when I run the above code, I am getting a saveAs DialogBox with (checkbox:Always ask before opening this type of file.) shown in disabled mode..
With disabled I mean, in non-editable mode i.e; I am not able to check or uncheck the box.
When i click on open button in the box, same box pops up second time with the checkbox in enabled mode. Now i am able to open the file.
I want this saveAs dialogBox with the checkbox in enabled mode when I run the code first time and not after I click on open button in the dialog box.
Can anyone workout a solution to my problem..
PLease its urgent...
or any other way to create the dialog box using code in c# or vb.net...
Vikram Mera
|
|
|
|
|
Hello,
I am starting a new Asp.Net 2.0 web site.I am looking for a fixed width web site.
I notice that CNN is using a 875px fixed width web site and Yahoo a 950px width web site. And many other web sites are using widths higher then 800px.
My question is:
What do you think of moving to widths higher then the 750px...780px usually used taking the 800px screens in consideration.
Thanks,
Miguel
|
|
|
|
|
That depends on your design. You can have a web page that wills the whole screen and looks good on any resolution (relative width's).
--------------------------------------------------------
My portfolio & development blog
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
According to this[^] 16% are still using 800x600.
You have to consider what kind of users you will have and if it's likely that they have chosen a higher resolution. On a site like this, for example, it's likely that almost everyone has the knowledge to change the screen resolution. However, if everyone has the knowledge, some will still choose to use a lower resolution for various reasons, like dyslexia or poor eyesight.
---
b { font-weight: normal; }
|
|
|
|
|
Hi,
I have a hyperlink column named change bound to a datagrid. In the datagrid I have 5 rows and 5 columns. I have a row named logo in which i will dsplay the images from database in an order and when i click the change button corresponding to the first row, it should be directed to a new popup window in which i have to dislay the corresponding logo of the first row in an image window and when i click browse and upload a new logo from the db the new logo should be displayed in the image window of the popup menu. i have done upto file uploading in popup but i dont know how to retrieve the image from the database and upload another image to db. my question is if we have to retrieve the image from the database do we have to create a new connection in the new window where the popup is created or we have to connect from the parent window (in which the datagrid is displayed). Pls provide me with a solution.
Thanx
saravanan
|
|
|
|
|
hi to all
i am stored the picture in database like this images\logos\country\1.jpg
my question is how to retrieve the picture and display <asp:image id="PictureBox1" style="Z-INDEX: 107; LEFT: 280px; POSITION: absolute; TOP: 144px"
runat="server" Height="32px" Width="88px"></asp:image>
this control
regards
saravanan
|
|
|
|
|
Hi there
first, it's
(images/logos/country/1.jpg) not (images\logos\country\1.jpg)
So u have 2 options
the first option is on Page_Load event use the following code
PictureBox1.ImageUrl= The path got from the database
OR use this in the aspx file ...
<asp:Image id="PictureBox1" style="Z-INDEX: 102; LEFT: 120px; POSITION: absolute; TOP: 128px" runat="server" Width="400px" Height="200px" ImageUrl='<#% getImagePath()#>'></asp:Image>
and in the code behind define:
public function getImagePath() As String
... any code to get the path of the image
Return (The image path got from the database)
End function
Hope it's helpful
Best Regards
3ala2
|
|
|
|
|