|
Hi All,
Does anybody know a way to access the tag that is generated when the ImageUrl property of a System.Web.UI.WebControls.HyperLink is set?
I'm trying to write some onmouseover code to the image. If I could get the ID (which isn't written to the source of the page) I could call a javascript function passing it the Image ID.
I think it may have something to do with RenderChildren method.
If anyone has any suggestions, your help is greatly appreciated.
Thanks,
Mike Kushner
mike@kushners.com
|
|
|
|
|
Extend HyperLink and add your own properties and / or events to do this, and then override Render to output your properties as HTML attribute for the IMG tag that is generated. There are several methods you can use to apply the styles and what-not for the control. It's all documented in the SDK documentation for WebControl .
Either that (easier), or output a script block (see Page.RegisterClientScriptBlock or Page.RegisterStartupScript - and you can get the Page in which the control is contained by using the control's Page property) that uses the ID to dynamically attach an event handler, although you have to then take the ClientID (as dictated by how the control is nested in one or more INamingContainer implementations, like the Page or a Panel ). The first method would definitely be easier.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Are you stuck maintaining VB.Net code when you prefer to work in C#? Our C-Sharpener For VB tool is a Visual Studio Add-in that converts VB.Net projects to C# projects. It translates the code and other project related files.
We are looking for a limited number of Beta Testers to help test our new tool. If you are interested, please go to
http://www.elegancetech.com/CSVB_Download.aspx?src=1
Thanks!
Roger Jack
Elegance Technologies, Inc.
www.elegancetech.com
|
|
|
|
|
I'm not sure how possible this is. It probably is doable (creating some kind of rich-client-side control), just not very wise. Certainly there will be a lot of security implications with this (i.e. Client Browsers not permitting anything dodgy to happen). Best bet might be with an ActiveX control.
Out of curiosity - Why do you want to access the serial port on a client machine via an ASPX page?
--Colin Mackay--
"In the confrontation between the stream and the rock, the stream always wins - not through strength but perseverance." (H. Jackson Brown)
|
|
|
|
|
I have a windows Form written in C#. I would like to "import" an Access MDB file into the project as a resource, then write this MDB file to dish at runtime. This was fairly simple in VC++ 6.0, but I'm finding little to no information about it in C#, any suggestions ?
Michael Malling
|
|
|
|
|
Whats the part you having difficulty with?
|
|
|
|
|
I've saved the MDB as an Resource template (RCT) file now i need to write it to disk...
|
|
|
|
|
|
Besides what Mark was saying, you can also add that MDB to your project and change the Build Action to "embedded resource". Then the file is added as an embedded resource when you compile and you can extract it easily:
Type t = this.GetType();
Stream s = t.Assembly.GetManifestResourceStream("Namespace.ResourceName.mdb");
Based on other things you posted, generally you still clear of resources the way you do them in VC++. Instead of string resources (or anything that can be represented as a string, hence those things with TypeConverters that can convert to/from strings) you use ResX files and a ResourceManager . Other files can be added as embedded resources. The VersionInfo block is automatically created by the linker using the assembly attributes.
You can still add/edit/remove an RC script using VS/VS.NET (opening the executable itself), but you have to delay-sign your assembly if you sign it (and you should). See my Windows XP Styles article for more information.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Heath Stewart wrote:
GetManifestResourceStream
That's what I was trying to remember.
|
|
|
|
|
Thanks for the replys, where do I change the Build Action ?
|
|
|
|
|
The RCT file I have created by importing the MDB does not have a build action option. I see it on the RESX files, but they seem to only hold strings...
|
|
|
|
|
What is an RCT file? You mean a RC script? If so, don't (see my previous comment). Instead, just right-click on your project (or a subfolder) and click Add Existing. Browse to the MDB file and double-click to add it to your project. Select the file in your solution explorer and you'll see a Build Action in the property grid. If you import an RC file into the executable (i.e., post-build) you'll have no way to access it through managed code. Like I said before, modifying the executable after compiling it is not a good idea since you're modifying the executable itself - not the assembly (which is a collection of modules and resources files, along with assembly attributes and the all-important MANIFEST (like JAR files also have). You can then use the Assembly.GetManifestResourceStream method to extract the MDB to wherever you want to put it.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Very kewl, I was importing the MDB as a Resource Template (RCT) file, but your way was exactly what i was looking for....thanks
|
|
|
|
|
ok, I imported the MDB as HL7Builder.dat into my project and added the following code:
Stream s = t.Assembly.GetManifestResourceStream("Namespace.HL7Builder.dat");
It errors when I try and read from the stream using s.ReadByte()
any thoughts ? Am I missing something ?
|
|
|
|
|
Guinness4Strength wrote:
Am I missing something ?
Yeah, replacing "Namespace" with the namespace of your resource!
When you add resources to your assembly via VS.NET, the namespace is created from the root namespace of the project (by default, your project name) plus any folders in which the resource is contained. So, if your project is "MyProject" and you create a folder in your project called "Databases" into which the MDB was added, then the fully-qualified resource name is "MyProject.Databases.HL7Builder.dat". If you're unsure, open your assembly with ildasm.exe (installed with the .NET SDK) and look at the manifest file. Toward the bottom (after the assembly references and assembly attributes, plus any public key info), you'll see .mresource Name. That full name is what you'd use in GetManifestResourceStream .
Also, why ReadByte ? You know how long that'd take you to write out the file? Use Read and Write with appropriate buffer sizes to make it much faster. 4096 is a good buffer size:
Type t = this.GetType();
Stream s = t.Assembly.GetManifestResourceStream
("MyProject.Databases.HL7Builder.dat");
Stream mdb = null;
try
{
byte[] buffer = new byte[4096];
mdb = File.Create("C:\TEMP\MyDB.mdb", buffer.Length);
int read = 0;
do
{
read = s.Read(buffer, 0, buffer.Length);
mdb.Write(buffer, 0, buffer.Length);
} while (read == buffer.Length);
}
finally
{
if (mdb != null)
{
mdb.Flush();
mdb.Close();
}
} This is just a basic example and you should add some decent exception handling, but hopefully you get the picture.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Thanks forall the info. The reason I used ReadByte, was that Read didn't work at first because I couldn't read off the stream, I am trying new things Once I cn read off the Stream I'll go back to Read using a byte buffer.
|
|
|
|
|
Right a file (your mdb) in the Solution Explorer, select propetries. You should see the build action property with choices of compile, content, embedded resource
|
|
|
|
|
Perhaps I'm not being clear, or I'm not understanding you.
I imported the MDB into an RCT file in my project which does NOT have a build option in its properties.
The RESX files DO have a build property, but these types of resourse files only appear to be able to hold string values. I need to acces the RCT file or perhaps theres another way to import the MDB file into an RESX file?
|
|
|
|
|
I was just thinking. Would it be better to distibute the mdb through a setup or is this not possible in your case?
|
|
|
|
|
I'm writing a simple little c# class to simply function as an alarm - you pass it a System.DateTime with the constructor, and when that time is reached, it fires an "Alarm" event. Simple enough. However, what's the most efficient way of doing this? Currently, I have thought of two ways. The first has a timer within the class that raises it's event every second or so, and each time it checks to see whether the time now is the same as the target time (accurate to the minute essentially, which is all that's neccesary).
The second is to work out how many milliseconds is between the time the control is enabled, and the target time, and set the interval to that. With repeat turned off, this means that in theory the timer will fire when the alarm is due, which is maybe more efficient than regular comparison checking?
Are these both crazy? Which is more sensible? Is the System.Timers.Timer accurate enough to do the second option anyway?
Am i missing a very easy way of doing this that is nothing like the above? Thank you very much in advance for any comments.
|
|
|
|
|
Yes, these options seem reasonable.
--Colin Mackay--
"In the confrontation between the stream and the rock, the stream always wins - not through strength but perseverance." (H. Jackson Brown)
|
|
|
|
|
Nothing crazy, these are probably the only two methods for accomplishing this. I'd go with the second method.
|
|
|
|
|
How to capture data from the local serial port through a Aspx page situated in a Web Server ??
NRS
|
|
|
|
|
This is ambiguous. Local to who? The client or the server?
--Colin Mackay--
"In the confrontation between the stream and the rock, the stream always wins - not through strength but perseverance." (H. Jackson Brown)
|
|
|
|