|
In .Net you can use System.Windows.Forms.PropertyGrid and some attributes like System.ComponentModel.Browsable , System.ComponentModel.Description System.ComponentModel.DefaultValue and System.ComponentModel.Category for more control over the behavior of the object
how ever if you don't want to use PropertyGrid you can do it by your self using the Type class with methods such as GetProperties().
then you can invoke members here is for property
<br />
<br />
Type myType=myObject.GetType();<br />
System.Reflection.PropertyInfo pi=myType.GetProperty("address");<br />
pi.SetValue(myObject,"street",null);<br />
<br />
and I remember there was a PropertyGrid in vb6.0 if you don't use .Net
I hope the post would be useful
|
|
|
|
|
The objects i will work on is not visual studio objects they are different classes and different objects... and i have to get their properties at runtime these objects are not design time objects.
thank you for your interest
sniper47 Computer Engineer
|
|
|
|
|
Same thing applies. All you have to do is put a PropertyGrid control on your properties form, and then at runtime do:
propertyGrid1.SelectedObject=control; ...where control is the control whose properties you want to show up in the property grid. Then the user can edit the properties without any need for Visual Studio at all. Seems too good to be true, huh? But it is - try it out!
--Justin,
Microsoft MVP, C#
|
|
|
|
|
The below is my code which was written in Webservices. Once I compile it , the "not all code paths return a value" error occurs.
Give the solution of it.
[WebMethod]
public string GetFile(string fileName)
{
string strGetFile = "";
try
{
SPWeb site = new SPSite(srcUrl).OpenWeb();
SPFile spFile = site.GetFile(srcUrl + "/" + fileName);
if (spFile.Length > 0)
{
byte[] fileArray = new Byte[spFile.Length];
strGetFile = System.Text.ASCIIEncoding.ASCII.GetString(fileArray);
return strGetFile;
}
return strGetFile="";
}
catch {}
}
|
|
|
|
|
your method is not void and you didn't handle the catch clause code
[WebMethod]
public string GetFile(string fileName)
{
string strGetFile = "";
try
{
.
.
.
}
return strGetFile="";
}
catch {}//catch{return null;} or catch{throw new Exception("your Exception");}
}
good luck
|
|
|
|
|
The return value of your method is a string, which requires that all exit points from your method provide a value to satisfy the compiler. The following example derived from yours is marked up to show the exit points...
public string SomeMethod(string fileName)
{
string strGetFile = "";
try
{
strGetFile = "some file name";
...
return strGetFile; //==> your optional exit point
}
catch
{
strGetFile = "";
...
return strGetFile; //==> your optional exit point
}
return strGetFile; //==> the main and only required exit point
}
Another way to handle it is to use only one exit point (this makes it easier to maintain as typically multiple exit points generally result in an increase in software maintenance costs over time)...
public string SomeMethod(string fileName)
{
string strGetFile = "";
try
{
strGetFile = "some file name";
...
//ensure the string is set and simply leave the try
}
catch
{
strGetFile = ""; //or some error message
...
//ensure the string is set and simply leave the catch
}
//execution resumes here after the try/catch block
return strGetFile; //==> the main and only required exit point
}
John
|
|
|
|
|
i have 3 page
maste page
header page in side the master page
defalut page
now i want from the default page to change image in header page
how i can do this ??
Palestine
|
|
|
|
|
See the replies in the C# Web Development forum, and don't cross post, please
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
I stand corrected
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Cool - but how did my post disappear?
"More functions should disregard input values and just return 12. It would make life easier." - comment posted on WTF
|
|
|
|
|
Whoa, beats me. I saw it myself earlier
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Today I ran into a problem with arraylists. And I can't seem to get why it doen't work. I have made the following function as below
When I use this function using statement A: result.Add(new string[] {subResult[0], subResult[1], subResult[2]}); I get this:
sr: rupert@doomsday.nl
sr: Rupert
sr: Monkey
sr: test@test.nl
sr: bart
sr: zuidgeest
rupert@doomsday.nl
test@test.nl
when I use statement B I get this output
sr: rupert@doomsday.nl
sr: Rupert
sr: Monkey
sr: test@test.nl
sr: bart
sr: zuidgeest
test@test.nl
test@test.nl
Notice the difference in the last two lines. Somehow when I use statement B I am left with only the second rusult in my arraylist twice instead of two different results. I need statement B because I cannot predict in advance what the amount of elements in each string array will be. Annyone want to tell me what's wrong? (Not that it should matter but this is on mono)
public ArrayList Search(string baseDN, int searchScope, string filter, string[] attributes)
{
ArrayList result = new ArrayList();
if (attributes == null || attributes.Length == 0)
{
return (result);
}
LdapSearchQueue queue = connection.Search ( baseDN, searchScope, filter, attributes, false, (LdapSearchQueue) null, (LdapSearchConstraints) null);
LdapMessage message;
string[] subResult = new string[attributes.Length];
while ((message = queue.getResponse()) != null)
{
if (message is LdapSearchResult)
{
int counter = 0;
LdapEntry entry = ((LdapSearchResult) message).Entry;
LdapAttributeSet attributeSet = entry.getAttributeSet();
foreach (string attributeName in attributes)
{
LdapAttribute attribute = attributeSet.getAttribute(attributeName);
subResult[counter] = attribute.StringValue;
counter++;
//Console.WriteLine("attr: " +attribute.StringValue + counter);
}
Console.WriteLine("sr: " + subResult[0]);
Console.WriteLine("sr: " + subResult[1]);
Console.WriteLine("sr: " + subResult[2]);
// A this works
//result.Add(new string[] {subResult[0], subResult[1], subResult[2]});
// B this doens't?
result.Add(subResult);
}
}
foreach(object a in result)
{
Console.WriteLine(((string[])a)[0]);
}
return(result);
}
|
|
|
|
|
That's not a mystery at all. It's a common mistake, and I believe that making it usually gives a better understanding about how objects and references work.
An ArrayList is a list of references.
With statement A you are creating a new array, and you add the reference to that array to the list. Each item in the ArrayList is a reference a separate array.
With statement B you are adding the reference in the subResult variable. As the variable never changes (only the contents of the array that it refers to), you end up with a list of references to the same single array, and that array happens to contain the last values that you put into it.
---
single minded; short sighted; long gone;
|
|
|
|
|
Ok, I entertained this posibility, But then I could not figure out why this does work:
ArrayList test = new ArrayList();
int[] numbers = new int[] {7,1};
test.Add(numbers);
numbers = new int[] {8,1};
test.Add(numbers);
foreach(object a in test)
{
Console.WriteLine(((int[])a)[0]);
}
this code gives me as result an 7 and then an 8 as I would expect .
But then I looked again and noticed the difference between this and my code is that I never create an new (string) array in my loop I just refill it. I should have noticed this an long time ago . I must realy like recreating objects. Tnanks Guffa for shaking me awake
|
|
|
|
|
hello
how can get pae name from URL
as this http://www.any.com/abc.aspx?ss=4
i want the result to be abc.aspx
????
Palestine
|
|
|
|
|
would that be everything ending at the first question mark, and starting
after the last slash before it ?
the string class has everything you need.
|
|
|
|
|
I'd rather use the Request object and its methods to access the different parts of the URL that do it myself with string operations.
see MSDN HttpRequest class for more information.
-^-^-^-^-^-
no risk no funk
|
|
|
|
|
<br />
Uri mine=new Uri("http://www.any.com/abc.aspx?ss=4");<br />
string path=mine.AbsolutePath
<br />
<br />
string name=mine.Segments[mine.Segments.Length-1];
|
|
|
|
|
how can get the URL from asp.net page ??
Palestine
|
|
|
|
|
if you mean getting the url of current page you can use
Uri pageUri=Request.Url;
if you need mapping or rewriting for url see:
http://www.codeproject.com/aspnet/urlrewriter.asp
http://www.simple-talk.com/dotnet/asp.net/a-complete-url-rewriting-solution-for-asp.net-2.0/
|
|
|
|
|
Hello everybody!!!!
I can find requisite form in my webbrowser.document.
Does anybody know how to submit that?
Please anybody answer me!!!!
|
|
|
|
|
I'm not sure understand what you means but if you filled some fields and want to click on a link or button to send it
it would be like this:
this.webBrowser.Document.All["submit"].InvokeMember("click");
submit is the button name and click is the method
however sometimes it does not work correctly. for that you can use unmanaged HTMLDocument
<br />
<br />
object domElement = this.webBrowser.Document.All["submit"].DomElement;<br />
mshtml.IHTMLElement hElemnt = (mshtml.IHTMLElement)domElement;<br />
hElemnt.click();<br />
<br />
to read a field you can use id of it (just like name or id of a button) and use GetAttribute() method
<br />
foreach (HtmlElement he in this.webBrowser.Document.All["verb[]"].All)<br />
MessageBox.Show(he.GetAttribute("value"));<br />
to write a field you can use id of it (just like name or id of a button) and use SetAttribute() method
for text areas you must use InnerText property instead of GetAttribute() and SetAttribute() Method.
I hope the post going to be useful
good luck
|
|
|
|
|
I make dataset and after that add the column into table in database.
Although I expand dataset with it, app dont recognize added column.
It's haped to me several times.
What can I do to avoid that?
Thanks.
|
|
|
|
|
Hi
Dataset is not manage your data like recordset it is fully offline storage of data. The values in Dataset is same as last hit on your db.
|
|
|
|
|
Hi everybody
I have a class defined as MyClass<T> .
Now in code I'd like to do something like this (Option is of type T ):
if(Option is bool)
return (bool)Option ? "Yes" : "No";
But I'm not able to cast from T to bool . How can I solve this?
regards
modified 12-Sep-18 21:01pm.
|
|
|
|