473,654 Members | 3,076 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Method Question?

I have the following situation.

I am creating my own user control.
This asp.net user control will have a method called "Read". When this
method is being called from the page. It will read line by line threw a
list dictionary. While reading line by line
it will be setting public properties that my page can access. So my user
control will look like this.

Usercontrol.asc x

public class clsUserControl
{
private string strMyPropertyVa lue;

public bool Read()
{
foreach(ListDic tionary MyListRow in MyListDictionar y)
{
strMyPropertyVa lue = (string)MyListR ow.Value;
}
}

public string MyReturnedValue
{
set
{
MyReturnedValue = strMyPropertyVa lue;
}
}
}

Now, my webpage called webpage.aspx.
Will do the following.

public class clsMyWebPage
{
//This will reference my usercontrol on the webpage.
protected clsUserControl MyUserControl;

private void DoSomething()
{
string strGetValue;
while(MyUserCon trol.Read())
{
strGetValue = MyUserControl.M yReturnedValue;
}
}
}

My question is this. How do I get my ".Read" method to loop through each
row setting the public property for each new value it retrieves
from the ListDictionary? Also, meanwhile setting the .Read method to
"true" so the calling page while loop will keep looping? I hope this makes
sense.

Thanks,
Mark

Nov 19 '05 #1
2 1195
Where oh where to begin?...

Have you ever done any programming? It looks to me like you're putting the
cart before the horse here. In this case, the cart is writing a program, and
the horse is learning to program. Without the horse, the cart is pretty much
useless.

You have a Method named "Read()" that returns a boolean value. However, it
doesn't return anything! In addition, I'm not at all sure what you expect
this function to do. As it stands, it will always assign strMyPropertyVa lue
the value of the last "ListDictionary " item in the "ListDictionary ." The
whole loop thing is pointless.

After that, you define a Property with only a Setter, no getter. This means
that you can NEVER read the value of the property, although in one line of
code you attempt to.

IOW, this code is one big cluster-f**k.

As to your question:
My question is this. How do I get my ".Read" method to loop through each
row setting the public property for each new value it retrieves
from the ListDictionary?
That's exactly what it does. See my earlier remark.
Also, meanwhile setting the .Read method to
"true" so the calling page while loop will keep looping?
Um. No. The boolean value of the Read Method is a RETURN value. Setting it
is not something a program can do.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.

"SouthSpawn " <so********@aol .com> wrote in message
news:31******** *************** *******@localho st.talkaboutsof tware.com...I have the following situation.

I am creating my own user control.
This asp.net user control will have a method called "Read". When this
method is being called from the page. It will read line by line threw a
list dictionary. While reading line by line
it will be setting public properties that my page can access. So my user
control will look like this.

Usercontrol.asc x

public class clsUserControl
{
private string strMyPropertyVa lue;

public bool Read()
{
foreach(ListDic tionary MyListRow in MyListDictionar y)
{
strMyPropertyVa lue = (string)MyListR ow.Value;
}
}

public string MyReturnedValue
{
set
{
MyReturnedValue = strMyPropertyVa lue;
}
}
}

Now, my webpage called webpage.aspx.
Will do the following.

public class clsMyWebPage
{
//This will reference my usercontrol on the webpage.
protected clsUserControl MyUserControl;

private void DoSomething()
{
string strGetValue;
while(MyUserCon trol.Read())
{
strGetValue = MyUserControl.M yReturnedValue;
}
}
}

My question is this. How do I get my ".Read" method to loop through each
row setting the public property for each new value it retrieves
from the ListDictionary? Also, meanwhile setting the .Read method to
"true" so the calling page while loop will keep looping? I hope this makes
sense.

Thanks,
Mark

Nov 19 '05 #2
Kevin,

It looks to me, as you are a typical programmer. NO PEOPLE SKILLS WHAT SO
EVER. WHILE I AM TRYING.
Another developer help me solved my problem. He at least knew how to help
people without trying to talk smack. Here is the solution I needed.

public class clsUserControl
{
IDictionaryEnum erator enumerator =
MyListDictionar y.GetEnumerator ();

public bool Read()
{
return enumerator.Move Next();
}

public string MyReturnedValue
{
get
{
return enumerator.Valu e.ToString();
}
}
}

You might be an Microsoft MVP, and that's all you will ever be.

Mark

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
7081
by: Ruud de Jong | last post by:
The question I have is: how safe / future proof / portable is the use of the __subclasses__ method that exists for new-style classes? Background: I thought I had found an easy-to-understand application for metaclasses: making classes instantly aware of their subclasses. The context was that I needed a class hierarchy, and I wanted to be able to instantiate subclasses by calling the root class. Which exact subclass would be instantiated...
7
15588
by: Edward Diener | last post by:
This simple code example gives me the message, "TypeError: 'staticmethod' object is not callable". class X(object): def Y(x): print x Y = staticmethod(Y) ad = { 1 : Y } def Z(self): self.ad(3)
1
2018
by: Oriane | last post by:
Hi, I'm currently a method attribute which is used to check the "validity" of this method against a rule. I wrote the isValid method, to be used inside the otriginal method: For instance: // Following is Csharp code private void functionT12 ()
18
4727
by: JohnR | last post by:
From reading the documentation, this should be a relatively easy thing. I have an arraylist of custom class instances which I want to search with an"indexof" where I'm passing an instance if the class where only the "searched" property has a value. I expected to get the index into the arraylist where I could then get the entire class instance. However, the 'indexof' is never calling my overloaded, overrides Equals method. Here is the...
9
5839
by: Steve Richter | last post by:
in a generic class, can I code the class so that I can call a static method of the generic class T? In the ConvertFrom method of the generic TypeConvert class I want to write, I have a call to the static Parse method of the conversion class. if (InValue is string) return T.Parse((string)InValue); else return base.ConvertFrom(context, culture, InValue);
1
1361
by: =?Utf-8?B?dG9iaXdhbl9rZW5vYmk=?= | last post by:
In the following code, calling CallTestMethod() from an instance of the derived class (the base is abstract and we can never instantiate it), referencing 'base.TestMethod()' actually calls 'TestMethod()' in the base class, but referencing 'this.CallTestMethod()' (defined in the base class) references the overriding method, not the method defined within the base class, making calling 'TestMethod()' seem virtually impossible (pun intended). ...
10
1789
by: Ugo | last post by:
Hi guys, until now I make so: <div id="my_div"><!-- content --></div> MyClass.prototype.doSomething = function( ) {}; MyClass.prototype.assignFun = function( )
2
2232
by: groups.kellyg | last post by:
If I have a web method called Log() and on the client I call BeginLog() with a null value for the AsyncCallback, will this cause a problem? I want to periodically Log messages to a Log web service but I don't need any return value. Is it poor programming practice to do it this way? Or is there a more preferred way? gkelly
0
8290
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8707
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8482
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8593
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6161
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4149
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4294
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2714
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1593
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.