|
I would like to be able to let people enter special fields and HTML into a Rich Textbox and then have it convert to HTML. Here is the plan. Let's just say I have these 2 fields, firstname and lastname. What I would like to have happen is to allow the end user to save this....
<br>#firstname#<br>#lastname#
into a text document and then I would have the app read the text document in, look through the doc for those special words and then replace them with the real values from the database. With that information I would just send it to browser object for display. What this is for is a phone integration and when the user clicks on the incoming call I would like them to see more information about who is calling. Giving the user a tool to add any fields they want and being able to format it anyway would be cool. I'm just not sure how to make sure everything stays HTML safe with chars like " ' / and the like. Anyone doing anything like this or could lead me into the correct direction please? Much thanks!
-- modified at 14:47 Monday 2nd July, 2007
|
|
|
|
|
Hello Everyone,
The last time I did any Windows/Win32 programming was before .NET was introduced!! Since then I've been focused on server-side Java applications but now I need to develop a Windows service. I figure C# should ease the transition into .NET and so I'm writing to this forum. If this is not the right forum for this question, please let me know which one is.
I'm looking for pointers on the quickest approach to go about implementing a service which listens in on both SMTP and POP3 traffic and based on the message headers perform some action. The behavior is just like an anti-spam application's service that monitor email.
So far, I've found sample code for creating a service. I'm hoping to find sample code for intercepting SMTP/POP3 traffic as well as an API similar to JavaMail which will help with parsing RFC822 messages.
If anyone here has previously developed an anti-spam application and is willing to be a consultant, please contact me directly. This would actually be my preferred approach.
Thank you.
Siraj.
Siraj Podikunju
SP Consulting, Inc.
sirajp@spconsult.com
|
|
|
|
|
Hi all, I want to download an xls file from remote location (Please note that its not FTP , its live ip, like myip/shared/info.xls) .I have been searching for any class or library but no success till yet. Can someone help me ? Thanks in advance.
Also, please guide how to open an excel file for reading data from it. Thanks
Kaliem
|
|
|
|
|
|
ah sorry, I forgot to inform, I am trying this with windows forms application, not web application, I guess incase of web, you can also do that using Response object, but I am looking for some control/class/library in windows app.
kaliem
|
|
|
|
|
What do you mean "remote location"? Across your network or the internet?
only two letters away from being an asset
|
|
|
|
|
Both! I want to be able to access files over my network and internet. like the file URL would be something like ipaddress/foldername/filename.xls
|
|
|
|
|
Process.Start("IExplore.exe", "\\ipaddress\foldername\filename.xls ");
Process.Start("IExplore.exe", "http:\\ipaddress\foldername\filename.xls ");
Provided the files is accessable from http of course.
only two letters away from being an asset
|
|
|
|
|
thanks for that, yes the file is accessible from http.
Yet to implement that code but my guess is, it would prompt the user to download that file. Is that possible if we can just save the file in a specific place instead of prompting.
Kaliem
|
|
|
|
|
Kaliem,
See my first response to your question. The component described in the article does what you are asking. It takes a URL to a file over HTTP and downloads it to a given location.
-----------------------------
In just two days, tomorrow will be yesterday.
|
|
|
|
|
Because the process being started is IE it will attempt to open the file just as any valid URI, however because of the file association IE will use MS Excel as the viewer. There is no need to download the file.
only two letters away from being an asset
|
|
|
|
|
Given the following class hierarchy and simple Program.Main
using System;
using System.Collections.Generic;
using System.Text;
namespace GenericTest
{
class Base
{
public void Name()
{
Console.WriteLine("I'm a Base class");
}
};
class Middle : Base
{
public new void Name()
{
Console.Write("I'm a Middle class");
}
};
class Child : Middle
{
public new void Name()
{
Console.Write("I'm a Child class");
}
};
class Program
{
static void PrintName<t>( T instance ) where T : GenericTest.Base
{
instance.Name();
}
static void Main(string[] args)
{
Child c = new Child();
PrintName<child>( c );
}
}
}
I see the following output
I'm a Base class
And I would have expected to see
I'm a Child class
Is this a bug with Generics or is it a side effect of how the Generic is generated for reference types?
Thanks
Matt Schuckmann
|
|
|
|
|
Hi,
it is correct by definition of the C# language.
You tell PrintName it is accepting objects of type Base,
hence instance.Name() actually is a call to Base.Name().
Exactly the same thing would happen when you do:
static void SomeMethod(Base instance) {
instance.Name();
}
If you want to get Child.Name() you should make Name() virtual and override it,
instead of using the "new" keyword.
|
|
|
|
|
The wayI understood the where statement is that I'm telling it to accept objects derived from type Base or that have the same interface as type Base. If I wanted to tell it to accept objects of type Base I wouldn't use a Generic I'd just use a simple method, like you suggested.
So your basically telling me that within a Generic you lose all static type information and everything is staticly bound and treated as if it was the type specified in the where statement. This is really sad your basicly telling me that a generic is no better than a class or method that takes a common ancestor class for whatever types you're going to pass it.
I understand making the method virtual to accomplish the intended results of this example but for reasons out side of this example I don't want the method to be virtual and I wanted to use the hiding semantics of the new keyword.
Thank You
Matt S.
|
|
|
|
|
mschuckmann wrote: The wayI understood the where statement is that I'm telling it to accept objects derived from type Base or that have the same interface as type Base.
That is correct; and it also applies to SomeMethod() in my example.
mschuckmann wrote: within a Generic you lose all static type information
That is not correct: you dont loose all information, both the Generic method and the
SomeMethod method accept Base objects or Base derivatives, and these objects keep their characteristics.
It is only the way you define your classes (thru the virtual/override/new keywords)
that decides whether you get the functionality of the base method or the more specialized
method. That has nothing to do with generics.
C# offers two ways to get the specialized method: by using the specialized type (Child.Name),
or by using virtual methods.
mschuckmann wrote: a generic is no better than a class or method that takes a common ancestor class
That is correct if you use where T : type.
But generics can be used without type constraint (acting somewhat like C++ templates).
And they can be used with more complex constraints; read up on "where" in MSDN for that.
|
|
|
|
|
Luc Pattyn wrote: That is not correct: you dont loose all information, both the Generic method and the
SomeMethod method accept Base objects or Base derivatives, and these objects keep their characteristics.
The objects themselves may keep their characteristics, because after all they are objects, but they no longer behave like themselves the with respect to non-virtual methods and this is counter intuitive to anyone who has done extensive template programing.
Luc Pattyn wrote: It is only the way you define your classes (thru the virtual/override/new keywords)
that decides whether you get the functionality of the base method or the more specialized
method. That has nothing to do with generics.
But the symantics of how they've implimented the generic feature makes the object behave differently with in the code of the generic (effectively making it lose it's type within the Generic), what is the point of providing the generic with specific type information (i.e. printName<child>(c) ) on the type I'm passing it if it's just going to ignore it and staticely the object to the lowest common denominator implimentation for non-virtual methods. In my opinion this hugely limits the functionality of generics when compared to templates and I find it hard to believe that anyone actually thinks this is good behavior.
Luc Pattyn wrote: That is correct if you use where T : type.
But generics can be used without type constraint (acting somewhat like C++ templates).
And they can be used with more complex constraints; read up on "where" in MSDN for that.
If you leave out the where constraint you've essentially specified a generic with a constraint of object and you can't call any methods except those declared by object. Therefore my example code will not compile without the where constraint. So sure you can impliment generics without type constraints but don't expect to do anything interesting in your generic code.
C++ templates effectively impliment constraints but much more flexibly and without any new confusing and limiting syntax. They do this by verifying any type they are instantiated with impliment (or claim to impliment) any methods that are is used by the template at compile time.
Thanks again
Matt S.
|
|
|
|
|
mschuckmann wrote: If you leave out the where constraint you've essentially specified a generic with a constraint of object and you can't call any methods except those declared by object. Therefore my example code will not compile without the where constraint. So sure you can impliment generics without type constraints but don't expect to do anything interesting in your generic code.
I do agree to your point of view, that the limitation of generics in regard to derived classes are unexpected. As a workaround you can use an interface, that defines the required methods, as the constraint. However, you must explicitly specify the interface for each class:
interface Named
{
void Name();
};
class Base : Named
{
public void Name()
{
Console.WriteLine("I'm a Base class");
}
};
class Middle : Base, Named
{
public new void Name()
{
Console.Write("I'm a Middle class");
}
};
class Child : Middle, Named
{
public new void Name()
{
Console.Write("I'm a Child class");
}
};
class Program
{
static void PrintName<T>( T instance ) where T : Named
{
instance.Name();
}
static void Main( string[] args )
{
Child c = new Child();
PrintName( c );
Console.ReadLine();
}
}
Regards,
Tim
|
|
|
|
|
I am trying to Bind data to DropDownLists and a CheckBox on differents Views of the MultiView. However I get an error whenever I try to Bind the Data. I did it in the Code Behind but cannot figure out what event in what object I should be putting the code in. Can anyone assist?
~Candi
|
|
|
|
|
Hope the Article by verinder bindra here[^] in CP will help you.
Regards,
Satips.
|
|
|
|
|
I have to insert 173 values from a DataTable into 173 existing fields in a SQL table. The values are of all different types. Any suggestions on doing this without taking a very very long way? Thank you!
Vicky
|
|
|
|
|
kissa49 wrote: Any suggestions on doing this without taking a very very long way?
By writing a simple C# program to do it?
|
|
|
|
|
right. i can just do an insert statement, except i have 173 fields and i have to specify each name and cast each data type
Vicky
|
|
|
|
|
Do you have a specific problem you need solving because we'll need more information if we're to help you?
|
|
|
|
|
Find your DBA, and ask him to write you a stored procedure for the insert on his massively dumb table, 173 columns is insane!
|
|
|
|
|
Yes, its a general table that gets normalized later. I have a DataTable containing the data that needs to go into this table. i was trying to do SQLBulkCopy, but that wouldnt work before the fields in the SQL table are of different data types and what goes in are Strings. So... I was trying to do insert SQL statements from the code.
Vicky
|
|
|
|