|
Half the answer[^].
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Execute below sql query agianest your database. It will retrieve all the tables availabale in the database you are using.
SELECT DISTINCT TABLE_NAME FROM information_schema.tables order by TABLE_NAME
Bind the resulted tabel to List box item
ListItem listImet;
lst.Items.Clear();
for (int i = 0; i < dt.Rows.Count; i++)
{
string Text = dt.Rows[i]["TABLE_NAME"].ToString();
listImet = new ListItem(Text);
lst.Items.Add(listImet);
}
Paly
|
|
|
|
|
Background:
To implement localization I have derived from DisplayNameAttribute: LocalDisplayNameAttribute. When using this attribute, I only want to declare the ResourceString an a default string. The class LocalDisplayNameAttribute should find out on it's own, which class and which assembly is using it.
My idea is, to find the strings in related resources by reflection. The strings should allways be in AssemblyName.Properties.Resources.
Is it possible for a attribute class, to find out, who it is used by?
Example:
Assembly LocalizationTools.dll
namespace LocalizationTools
{
public class LocalDisplayNameAttribute : DisplayNameAttribute
{
public LocalDisplayNameAttribute(string resourceName, string defaultText)
: base(defaultText)
{
m_resourceName = resourceName;
}
public override string DisplayName
{
get
{
string name = string.Empty;
try
{
name = SomeVodoo(base.DisplayNameValue);
}
catch (Exception)
{
name = base.DisplayNameValue;
}
return name;
}
}
private string SomeVodoo(string defaultText)
{
}
}
}
Assembly SomeClasses.dll
public class Foo
{
[LocalizationTools.LocalDisplayName("DisplayName_ImportantProperty", "Important property XYZ")]
public int ImportantProperty { get; set; }
}
And in SomeClasses.Properties.Resources you can find DisplayName_ImportantProperty
PS: I have a IMO less elegant solution by declaring the type.
[LocalizationTools.LocalDisplayName(typeof(SomeClasses.Properties.Resources), "DisplayName_ImportantProperty", "Important property XYZ")]
public int ImportantProperty { get; set; }
}
Thanks in advance
Andy
|
|
|
|
|
You don't. An atribute should NOT EVER modify its behavior based on the class name it's attached to. The reason is that now your attribute functionality is directly tied to the classes it's looking for. That's bad!
If you need to modify the behavior of the attribute, then you need two or more attributes, one for each behavior.
|
|
|
|
|
Hi Dave,
thanks for your answer.
Well, I did not want to change the behaviour of the attribute. It still should show the DisplayName, Description, Category etc. I only wanted to make it a bit more "smart" regarding localization.
I was just curious, if it is possibly for an attribute to figure out to which class it is attached.
It's ok for me, since I have a solution, inspired by different approaches which can be found here at CP and out in the web.
|
|
|
|
|
I'm fairly sure you can't do this without using a typeof(...) to pass it to the attribute's constructor.
|
|
|
|
|
Thx for your answer.
Well, I have to accept my destiny and I'll choose the typeof operator in the constructor.
As I mentioned before, I was just interested if it could be possible
|
|
|
|
|
Hello. I am using a hastable to store and retrieve class objects. Now I can successfully get an object based on some key but the problem is: I can not return it from within the function. Here is what I am trying
public ClassName FindObject(int nKey)
{
ClassName obj = new ClassName();
obj = (ClassName)HashTable[nKey];
return obj;
}
Now the line (ClassName)HashTable[nKey] is successful to find the required object but obj is still equal to null. Thanks for any input on this.
This world is going to explode due to international politics, SOON.
|
|
|
|
|
Hashtable hashtable;
private void button1_Click(object sender, EventArgs e)
{
Test t1 = new Test();
t1.variable = 1;
Test t2 = new Test();
t2.variable = 2;
hashtable = new Hashtable();
hashtable.Add(1, t1);
hashtable.Add(2, t2);
Test tc1 = GetClass(1);
tc1.ShowVar();
Test tc2 = GetClass(2);
tc2.ShowVar();
}
public Test GetClass(object id)
{
return (Test)hashtable[id];
}
}
public class Test
{
public int variable;
public void ShowVar()
{
Console.WriteLine(variable);
}
}
|
|
|
|
|
Can you post the code using the function FndObject?
The code you posted above doesnt seem to have any problems.
|
|
|
|
|
Why are you creating a new ClassName instance when the variable obj id immediately overwritten in then next statement?
The next thing you don't understand is that trying to retreive a an object via a key from a Hashtablehttp://msdn.microsoft.com/en-us/library/system.collections.hashtable.item(v=vs.80).aspx[^] will return null when there is nothing stored under that key:
MSDN wrote: The value associated with the specified key. If the specified key is not found, attempting to get it returns a null reference (Nothing in Visual Basic), and attempting to set it creates a new element using the specified key.
So what happens here is that whatever you passed into FindObject as a key has no instance of type ClassName associated with it.
Regards,
— Manfred
"I had the right to remain silent, but I didn't have the ability!"
Ron White, Comedian
|
|
|
|
|
Furthermore, the element at nKey may not be of type ClassName or a derived class - then the cast to ClassName will change it to null.
|
|
|
|
|
Hi can anybody plesae tell me is there any opensource BPM for .net rather than www.netbpm.org......
Thanks in advance
modified 5-Oct-12 2:36am.
|
|
|
|
|
DON'T SHOUT. Using all capitals is considered shouting on the internet, and rude (using all lower case is considered childish). Use proper capitalisation if you want to be taken seriously.
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
I am developing C# application.desktop application.
I am using Visual Studio 2010 & SQL server 2008
I am new to C#.
If I want to print a bill by taking a total of entry filled text boxes(i.e. printout of selected items only or non empty text boxes)then how will I do it?
I 'Bill' form I have taken 20 fileds for exa. nursing charges,anesthesia charges,likewise..
Different treatment requires different types of charges so,i will do entry only in selected fields among these 20 fields.
Bill printout should contain the fields which I have entered.
How will I do this?
Can anybody please help me?
Thank in advance.
|
|
|
|
|
S Akshay wrote: How will I do this?
Can anybody please help me?
With picking a report-generator? How about starting on MSDN[^]?
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
How to trigger C# events using jquery
|
|
|
|
|
You might find this[^] a useful starting point.
|
|
|
|
|
I hope it may help you..
JQuery:
$(document).ready(function () {
$('#button1').click(function (event) {
$('#button2').click();
event.preventDefault();
return false;
});
});
HTML:
<asp:Button runat="server" ID="btn1" onclick="btn1_Click" Text="Button One" ClientIDMode="Static" />
<asp:Button runat="server" ID="btn2" onclick="btn2_Click" Text="Button Two" ClientIDMode="Static" />
<asp:Label runat="server" ID="lbl2"></asp:Label>
code behind for button2 click event:
protected void btn2_Click(object sender, EventArgs e)
{
var test2 = "test2";
lbl2.Text = "btn2_Click";
}
Paly
|
|
|
|
|
When I try to write to a comment tag field and save the file, I get either expected result, wrong result or an error. Does anyone have suggestions or tips? The intent is to add text to the metadata of jpg images so that I can search images later. Here's the code sofar:
private void buttonOpenFile_Click(object sender, EventArgs e)
{
using(OpenFileDialog d = new OpenFileDialog())
{
d.InitialDirectory = @"D:\";
d.Filter = "All jpeg files|*.jpg;*.jpeg";
d.ShowDialog();
_File = TagLib.File.Create(d.FileName,"image/jpeg", TagLib.ReadStyle.None);
}
textBox1.Text = _File.Tag.Comment;
}
private void buttonSaveFile_Click(object sender, EventArgs e)
{
_File.Tag.Comment = textBox1.Text;
_File.Save();
}
|
|
|
|
|
|
I already studied all i could find...no solution sofar!
|
|
|
|
|
Please help me how i read equation from word and display on asp .net page.
|
|
|
|
|
Please read this[^].
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Hello. I dont know deeply about this but; I know that private inhertience most likely means composition. Now I am using private inheritence in my small c++ project like this
BOOL ChildClass::Function()
{
return BaseClass::Function();
}
Now there is no private inhertence in C#. I can use composition here but how will I call BaseClass functions in ChildClass like above. How do I achieve this in C#? Thanks
This world is going to explode due to international politics, SOON.
|
|
|
|