Re: Logic Question about Public Method I created.
- From: Matt Berther <mberther@xxxxxxxxxxx>
- Date: Mon, 11 Apr 2005 09:55:55 -0700
Hello SouthSpawn,
Perhaps you are interested in doing something along the lines of an event...
public delegate void MyPropertyValueReceivedHandler(string value);
public class clsUserControl
{
public event MyProertyValueReceivedHandler MyPropertyValueReceived; public void Read()
{
foreach(ListDictionary MyListRow in MyListDictionary)
{
if (MyPropertyValueReceived != null)
{
MyPropertyValueReceived((string)MyListRow.Value);
}
}
}
}Your calling code then only wires up its interest in the MyPropertyValueReceived event and does what it needs to...
public class clsMyWebPage
{
protected clsUserControl MyUserControl; private void DoSomething()
{
MyUserControl.MyPropertyValueReceived += new MyPropertyValueReceivedHandler(HandleProperty);
MyUserControl.Read();
} private void HandleProperty(string s)
{
// do something...
}
}You can get more information about events by googling C# events.
-- Matt Berther http://www.mattberther.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.ascx
public class clsUserControl { private string strMyPropertyValue; public bool Read() { foreach(ListDictionary MyListRow in MyListDictionary) { strMyPropertyValue = (string)MyListRow.Value; } } public string MyReturnedValue { set { MyReturnedValue = strMyPropertyValue; } } } 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(MyUserControl.Read()) { strGetValue = MyUserControl.MyReturnedValue; } } } 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
.
- References:
- Logic Question about Public Method I created.
- From: SouthSpawn
- Logic Question about Public Method I created.
- Prev by Date: Re: Application Icon
- Next by Date: Send Mail
- Previous by thread: Logic Question about Public Method I created.
- Next by thread: Send Mail
- Index(es):
Relevant Pages
|