|
actually that's what i'm doing. but infragistics webgrid columns seem to accept just real-properties...
regards, andré
|
|
|
|
|
I need a help.
if i only click the master data grid link column, it has to pass that column value & display details in the grid below the master gird in the same asp.net form.( both master and details has to display)
i set the target as self,but it displays only the details grid.
help will be appriciated.
thanks
|
|
|
|
|
Your question belongs in the ASP.NET forum.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
How can i arrange data in an xml file alphabetically?
<?xml version="1.0" ?>
<names>
<name>>Matt Daimon</name>
<name>Kate Winsilet</name>
<name>Martha Stewarts</name>
<name>Will Smith</name>
<name>Britiny Spears</name>
<name>Jenifer Lopez</name>
<name>Jenifer Aniston</name>
</Names>
<pre>
Plz any sort of help will be gr8!
|
|
|
|
|
That's a rather ambiqous question. Do you want to have it sorted in the file and rewritten? You can do that with an XSL Transform that looks like so:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" version="1.0" standalone="yes"/>
<xsl:template match="Names">
<xsl:element name="Names">
<xsl:apply-templates select="Name">
<xsl:sort select="."/>
</xsl:apply-templates>
</xsl:element>
</xsl:template>
<xsl:template match="Name">
<xsl:element name="Name">
<xsl:value-of select="."/>
</xsl:element>
</xsl:template>
</xsl:stylesheet> To transform the XML, you can do something simple like this:
using System;
using System.IO;
using System.Xml;
using System.Xml.XPath;
using System.Xml.Xsl;
class Test
{
static void Main(string[] args)
{
if (args.Length != 2) Environment.Exit(1);
Transform(args[0], args[1]);
}
static void Transform(string xml, string xsl)
{
XmlDocument doc = new XmlDocument();
doc.Load(xml);
XslTransform tran = new XslTransform();
tran.Load(xsl);
tran.Transform(doc, null, Console.Out, null);
}
} If you just want to read the data in and sort it, you can do something like this:
using System;
using System.Collections;
using System.IO;
using System.Xml;
class Test
{
static void Main(string[] args)
{
if (args.Length != 1) Environment.Exit(1);
Sort(args[0]);
}
static void Sort(string file)
{
XmlDocument doc = new XmlDocument();
doc.Load(file);
XmlNodeList nodes = doc.DocumentElement.SelectNodes("/Names/Name");
string[] names = new string[nodes.Count];
int i=0;
foreach (XmlNode node in nodes)
names[i++] = node.InnerText;
Array.Sort(names, Comparer.Default);
foreach (string name in names)
Console.WriteLine(name);
}
} There's practically an infinite amount of ways you can sort this data - it just depends on your needs.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
How would I go about searching for a specific file on my local drives at runtime.
Something like this (psuedo code)
if (searchForFileMethod('myFile.dat')
// get the path to the file
else
// inform the user that file is not found
Any hints or tips would be appreciated.
Thanks,
Einar
|
|
|
|
|
A recursive method that calls Directory.GetFiles and Directory.GetDirectories
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Thanks for the reply. That is just what I needed to get started. I figured it had to be something recursive.
Thanks,
Einar
|
|
|
|
|
Hello -
I'm working on a gui using Gtk in C#. My gui is periodically updated by a background thread to display status information. My problem is that the gui only refreshes the screen when the mouse moves over it. What I really need is for the gui to automatically refresh whenever it is updated.
I've seen posts that suggest using ThreadNotify to fix this problem. ThreadNotify does fire the method that I pass it, but the gui is still not refreshed until I move the mouse.
I've also tried using QueueDraw(), both on the Window and on the TextView that I am updating, but again it does not refresh correctly.
Any suggestions would be much appreciated.
Thanks!
Some test code that I have been playing around with follows:
namespace Test {
using System;
using System.Threading;
using Gtk;
using Glade;
using GtkSharp;
public class Test
{
[Glade.Widget] private TextView textview1;
[Glade.Widget] private Button button1;
[Glade.Widget] private Window window1;
private TextBuffer tb;
private ThreadNotify tn;
private Thread t;
private int cnt = 0;
public Test()
{
Gtk.Application.Init();
Glade.XML gxml = new Glade.XML (null, "test.glade", "window1", null);
gxml.Autoconnect (this);
tb = new TextBuffer(null);
textview1.Buffer = tb;
tn = new ThreadNotify( new ReadyEvent(Ready) );
t = new Thread(new ThreadStart(Fill) );
t.IsBackground = true;
Application.Run();
}
public void Fill()
{
int i = 0;
for ( ; ; )
{
cnt = i;
i = (i < 100) ? (i + 1) : 0;
tn.WakeupMain();
}
}
public void Ready()
{
tb.Insert(tb.EndIter, cnt.ToString() + "\n");
}
public void OnWindow1DeleteEvent (object o, DeleteEventArgs args)
{
t.Abort();
Application.Quit ();
}
public void OnButton1Clicked(object o, EventArgs args)
{
t.Start();
button1.Sensitive = false;
}
public static void Main()
{
Test t = new Test();
}
}
}
|
|
|
|
|
See Refresh . This forces an immediately invalidation and redraw of the control. Of course things work a little differently with GTK so I'm not sure. Since this is primarily a Microsoft development site, you might check with other sites more appropriate for CLI apps on non-Microsoft systems (or using non-Microsoft APIs like GTK).
Also, be sure than when you're updating your controls from a separate thread you do so in the thread that created the control using InvokeRequired and Invoke . We've discussed this many times in this forum, and you can click "Search comments" above to find those discussions if you're interested in learning more.
Again, though, that's true on Windows platforms. Of course, with the way threads are handled this is probably true on any platform.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
I have an application that is using a panel to hold a bitmap, for a skin. What I wanted to do was to load the app, then launch the function on form load. It takes a few seconds to load the form, but by the time the form has finaly loaded the update process on the application is already complete. I need my users to know that an update took, place using a progress bar.
What is the easiest way to check that the main form is loaded, prior to the function firing ?
D
|
|
|
|
|
Seems like you are trying to do a something like a splash screen. If you application starts so fast maybe you can find a better way of notifing the user that an update took place.
|
|
|
|
|
Basically just looking to delay my function from firing right away.
|
|
|
|
|
A delay can be achieved with a Timer.
Set your timer interval to a specified amount of time (1000 = 1 second)
when your application starts, start the timer as well
In your timer TICK event, stop and dispose the timer, and execute your update function.
Jon G
www.Gizmocoder.com
|
|
|
|
|
One way would be to hook an event handler to Application.Idle in the handler you have for Form.Load. The Idle event will be raised right after the Form is actually visible to the user. Remember to unhook your handler for Application.Idle in your handler for it.
You could also use BeginInvoke, which basically uses WM_POST to acheive a delayed call. So at the end of your Form.Load handler, you could do something like "BeginInvoke(new EventHandler(MyFunction));"
|
|
|
|
|
Hi all,
In MAPI C# programming, I find that I can only send email to the
outlook express "out" folder, but can't program MAPI to ask it to send
the email directly. What should I do ?
Thanks
|
|
|
|
|
That's what the Mail API does. An server application implements the API which you use. What the server application does is up to its implementation.
If you want to send email directly, consume the SMTP protocol. I recommend you click "Search comments" directly above this forum and search for "SMTP". We've discussed this several times, and I have posted code before to get the MX record of the mail server (which is the server that you connect to over port 25) at http://www.codeproject.com/aspnet/emailvalidator.asp?msg=305731#xx305731xx[^].
The SMTP protocol is actually a very simple protocol, BTW, and you can read more about it at http://www.ietf.org/rfc/rfc0821.txt[^].
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Hello all.
I'm handling the keypress event of a data grid. I would like to know if the CapsLock key is pressed or not, but I haven't found nothing to do it.
Is possible this ? Can anyone help me ?
Thanks.
|
|
|
|
|
|
Great. Thank you very much
|
|
|
|
|
Topic cont'd... of type 'System.Data.Odbc.OdbcException' occurred in system.data.dll
Additional Information : System error
First of all hello, this is my first post, great site here, seems like their a lot of knowledgable people. Anyway I am just beginning to learn C#. I am creating a program for where I work for employees to login with a username and password and after successfully logging in they can clock in and clock out.
I am working on the login page first, known as form1 in my project. When the user clicks the "Login" button(known as button1) I would like it to load the next form where the user will be able to clock in and clock out. All the usernames and passwords are on a Access table. They will not be able to create their own but just use the preset ones. I want the program to check if what the user entered in as the username and password match whats on the table and if it does not, then it will display an error.
Here is a little snip of my code and I will point out which line the error points to:
public void button1_Click(object sender, System.EventArgs e) <br />
{ <br />
OdbcDataReader myReader; <br />
string myConnString = "DSN=MS Access Database;DefaultDir=C:\\DOCUMENTS AND SETTINGS\\OWNER\\MY DOCUMENTS;DriverId=25;DBQ=C:\\DOCUMENTS AND SETTINGS\\OWNER\\MY DOCUMENTS\\login.mdb;MaxBufferSize=2048;FIL=MS Access;PageTimeout=5;UID=admin"; <br />
string mySelectQuery = "SELECT Username, Password FROM tblLogin WHERE Username = " + txtUserName.Text; <br />
OdbcConnection myConnection = new OdbcConnection(myConnString); <br />
OdbcCommand myCommand = new OdbcCommand(mySelectQuery,myConnection); <br />
myConnection.Open(); <br />
[CODE]myReader = myCommand.ExecuteReader();[/CODE] <br />
while(myReader.IsDBNull(0)) <br />
{ <br />
lblErrorUser.Visible=true; <br />
}
The error points to the myReader = myCommand.ExecuteReader() line.
It does open the connection fine but when I click the Login button the error above comes up. If I comment in that line(using //) and the while loop, the program runs fine, well doesnt do what I want it to do but when I click the Login button it opens form2.
I believe it has something to do with the myReader variable. I have declared it as OdbcDataReader myReader where I have all my functions declared. I just noticed that their is a blue squiggly under the myReader where its declared.
Also, just want to mention that before this 'system error' I was recieving the following error: Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
and it was still pointing at the myReader = myCommand.ExecuteReader(); I did not change anything and all of a sudden I was recieving the system error. It still points at the myReader variable though.
Help is greatly appreciated. Thanks!
|
|
|
|
|
The problem you're having is that Username is a string field, so you need to quote your field:
"SELECT Username, Password FROM tblLogin WHERE Username = '" + txtUIserName.Text + "'" BUT NEVER, EVER build SQL expressions using concatenation.
Sorry, but that isn't very smart at all. What if I pass "blah' AND 1=1; drop table tblLogin" from your TextBox ? Bye bye login table. It's even worse that you store passwords in plain text. I could, instead, select all those and impersonate any user on your system. Can you say "lawsuits"?
Read http://www.codeproject.com/script/comments/forums.asp?msg=932507&forumid=1649&XtraIDs=1649&searchkw=parameterized&sd=7%2F8%2F2004&ed=10%2F6%2F2004#xx932507xx[^] for other problems and more things I could do using your SQL concatenation code.
ALWAYS use parameterized queries. Read the link above for an example, or the OleDbParameter class documentation in the .NET Framework SDK.
Also, your expression is very insecure besides not using parameterized queries. Don't select the password as part of the result set. Send the password and use it in the WHERE clause like so:
SELECT COUNT(*) FROM tblLogin WHERE Username = ? AND Password = ? In fact, even that's bad. You should never store passwords in plain text. Hash them using a one-way algorithm like MD5 or SHA1, both of which are supported by the .NET Framework base class libraries (see the MD5 and SHA1 class). Hash the password before sending it to the database server (and I assume this is actually for an ASP.NET application, which belongs in the ASP.NET forum but I'll continue anyway) or across the wire, then compare that to the hash you store in the Password field (using the same query as above).
In fact, even that's insecure. It's subject to replay attacks where someone sniffs your password and while they might not be able to unhash or decrypt it (at least with a given amount of time and resources), they could simply capture the packets, play them back, and you've been 0wned. Instead, store a salt, send it to the client, hash your password + the salt value and send it back to the server.
You should really read many of the good security Patterns and Practices books regarding .NET at http://msdn.microsoft.com/patterns[^].
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
We have a requirement to run a .Net app from a VB6 app. This is no real problem as I'm not doing the VB6 side but is it possible to create a registry entry with the install path of the .Net app at the time of install?
I could populate the reg entry at run time no problem, but this would mean the app must be run once before being called externally.
Alternatively is it possible to run an app atuomatically after an install, so the reg entry can be completed at run time.
Any suggestions welcome, Thanks
|
|
|
|
|
This greatly depends on the setup technology you're using. If you're using an actually installation technology like Windows Installer, InstallShield setup, Wise setup, Nullsoft setup, or anything else then you can write a registry key with the path of the executable. If you're just doing XCOPY deployment (or otherwise dragging and dropping) then no.
You need to consult your installation builder documentation for this. This is not a C#-related question.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
I'm trying to create a custom control in a dll. The class is inherited from the System.Windows.Forms.Panel class. On this new class i place a couple of labels and another panel, but when i add this control on a windows form, i only see the outline of the control but nothing on it. I tried the same thing with the System.Windows.Forms.Usercontrol class and that worked fine, but the moment i inherit from the panel class the trouble starts.
Can anyone tell me what i'm doing wrong?
Thanks,
Reinier.
|
|
|
|