|
hi
please... i try..... but i dont know java-script......
if someone can help me... i'll be grateful
this:
http://static.peace-love-freedom.net/js-itm/trunk/jsdoc/symbols/src/js-itm.js.html
thank's in advance
|
|
|
|
|
Then start learning.
This code is simply creating a class with some methods, i.e. functions
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
See, Javascript is a client end language that runs in the browser, while C# is the code that runs in the server. Just put all the data you need in JSON format and send it using AJAX to a handler. You can also use hiddenfield or XML or by any means. Now from Server use the handler to parse JSON object and get the data.
Read about AJAX and also start learning the basics of C#.
Abhishek Sur
Don't forget to click "Good Answer" if you like this Solution. Visit My Website-->www.abhisheksur.com
|
|
|
|
|
Google and do some hands-on JavaScript
// ♫ 99 little bugs in the code,
// 99 bugs in the code
// We fix a bug, compile it again
// 101 little bugs in the code ♫
|
|
|
|
|
|
Is it possible to dynamically adding custom attributes to class methods or properties? If so any examples will be appreciated.
|
|
|
|
|
No
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Man, way to crush his dreams
|
|
|
|
|
Try This [^]
I know nothing , I know nothing ...
|
|
|
|
|
This is using codedom to write code dynamically not dynamically adding an attribute to existing code. They are not equal.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Would compiling code at runtime suffice (e.g., creating a new class with methods/properties that have the custom attributes)? That can be done.
|
|
|
|
|
don't kill the pianist, but I thing I did somethings related to this. It was some time ago and I don't have that resources, but here is the catch.
There was a way to specify what property "descriptor" to use for a specific class. From that class, you call the default property descriptor and modify the returned list of attributes as you wish. Sorry if the terms are not quite accurate but they may bring up someone [else?] idea about how to do this.
|
|
|
|
|
If it's possible to dynamically add custom attributes to a class, you'll be jumping through so many hoops to do so that perhaps a better question to ask is: "am I trying to do something I shouldn't be trying to do?"
Also, by attempting to do something so far "outside the box" of .Net programming as it was intended by MS that you'll potentially be creating a maintenance problem for whoever works on the code after you.
If you need to dynamically decorate a type, property, etc. with attribute-like information, perhaps a wiser design is to implement your own repository of such information (perhaps a static Dictionary<MemberInfo, MyCustomAttribute> , or some such). If necessary, you can initialize it from the complier-built attributes, but that should be the end of your logic's relationship with attributes.
Just a thought.
|
|
|
|
|
My class exposes some controls via properties. I need to invoke certain properties of these controls that are decorated with my custom attributes. So let’s take example. Here is how my class look like
public partial class Form1 : Form
{
public Control Button1
{
get { return this.btn1; }
}
[MyCustomAttributes]
public Control Button2
{
get { return this.btn2; }
}
}
Now I want to dyanmically call Visible property to false on the Control properties that are decorated with MyCustomAttributes attribute.
PropertyInfo[] PI = typeof(Form1).GetProperties();
foreach (PropertyInfo property in PI)
{
MyCustomAttributes myAtt = (MyCustomAttributes)Attribute.GetCustomAttribute(property, typeof(MyCustomAttributes));
if (myAtt == null) continue;
property.SetValue("Visible", false, null); }
But I get exception that "Property set method not found". Any ideas what I am doing wrong here?
|
|
|
|
|
imak wrote: property.SetValue("Visible", false, null);
The property in this case is not the same as the control. "property" is actually your "get" method on Form1 to RETRIEVE the control. Try this:
Control ctl = (Control)property.GetValue(Form1, null);
ctl.Visible = false;
|
|
|
|
|
How dare you beat me by seconds with the same answer!
|
|
|
|
|
And I even added a (very) brief explanation... Ha! I win the prize!
Wait... There's no prize?
|
|
|
|
|
I get following error now
Form1 is a 'type' but is used like a 'variable'
|
|
|
|
|
Ok, well plug in the current instance of Form1... If you're running this code inside the form, it'd just be "this"... If you're running it elsewhere, then, well, I assume you have a reference to the form, so pop that in there.
|
|
|
|
|
What you want to do is:
Control control = (Control)property.GetValue(obj, null);
control.Visible = false;
|
|
|
|
|
But property is not a keyword, and null is.. what happened to the colouring?
|
|
|
|
|
I rewrite my variable names when I post answers. Ie, I was almost going to use propertyInfo instead of using property but I figured it would be too confusing.
|
|
|
|
|
Ok, but that doesn't explain how property is blue and null is not
|
|
|
|
|
Oh, I just looked at my post. I had no idea what you are talking about. Ask the site admins if you want to know what crazy stuff happens not me
|
|
|
|
|
You need to take some responsibility for the craziness too; a PRE or CODE tag accepts an optional LANG attrribute where you specify the language, and hence the applicable list of keywords. More information can be found here[^].
By default the language stuff is handled automatically when pasting in Q&A (based on code I provided here: PRE tags galore: LPCodeRecognizer[^]).
So far Chris hasn't been willing or able to implement it also in the forums. There is a default, unfortunately it is C++ everywhere (and not C# as was documented somewhere), and independent of the actual forum.
And then there are some bugs in the syntax colorizer, IIRC it is easily confused by quoted stuff.
Conclusion: the best you can do is change <PRE> into <PRE lang="CS"> and hope for the best.
|
|
|
|
|
That's what you get to see in a pre-tag without specifying the language;
Control control = (Control)property.GetValue(obj, null);
This is with the language set to C#;
Control control = (Control)property.GetValue(obj, null);
I are Troll
|
|
|
|