Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
Zhentar
Sep 28, 2003

Brilliant Master Genius
Seeking a file vs copying it to memory is probably not that big of a difference. The OS is loading the file to memory and reading from there anyway whether you tell it to or not.

Adbot
ADBOT LOVES YOU

PDP-1
Oct 12, 2004

It's a beautiful day in the neighborhood.

Rahu posted:

Really easy question because I can't figure out what to type into the google.

I'm learning winforms and making a very simple program to try out various stuff, and I'm trying to add a small options screen with some configuration info in it.

What I want to do is make it impossible for the main window to have focus as long as the options window is up, as many programs do. I'm sure there's some simple way to accomplish this but I can't seem to find it.

Create your options form and then show it using OptionsForm.ShowDialog() to get that effect. You can also assign buttons on the options form to have a DialogResult property that will be returned when the OptionsForm is closed to help you decide what to do with the result. Something like

code:
OptionsForm optionsForm = new OptionsForm;

if(optionsForm.ShowDialog() == DialogResult.OK)
  { // apply new options }
This would apply the new options if the user closed the OptionsForm by clicking an 'OK' button or would ignore the new options if the dialog got closed in some other way, like clicking the red X or a Cancel button.

gnatalie
Jul 1, 2003

blasting women into space
The form's ShowDialog method should do it :)

http://msdn.microsoft.com/en-us/library/c7ykbedk.aspx

edit: snap

Frozen Peach
Aug 25, 2004

garbage man from a garbage can

PDP-1 posted:

code:
OptionsForm optionsForm = new OptionsForm;

if(optionsForm.ShowDialog() == DialogResult.OK)
  { // apply new options }
This would apply the new options if the user closed the OptionsForm by clicking an 'OK' button or would ignore the new options if the dialog got closed in some other way, like clicking the red X or a Cancel button.

Forms aren't automatically garbage collected, so you really should put the form in a using statement. Otherwise you have a memory leak as more and more options windows are opened/closed.

code:
using(OptionsFrom options = new OptionsForm)
{
    if(optionsForm.ShowDialog() == DialogResult.OK)
        { // apply new options }
}
You should note that ShowDialog() will stop execution until it returns, whereas Show() will fire up the form and the original form keeps on running like normal. This is very handy for things like an options form, but if you're doing something like a progress form that needs to be shown and have code on the original form keep running it gets slightly more complicated.

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Is there a better way to do this?
code:
private void FSWatcher_FileChanged(object sender, FileSystemEventArgs e){
	var justInCase = 4;
	while(justInCase > 0){
		try{
			databaseObject.Content = File.ReadAllText(e.FullPath);
			break;
		}catch(IOException ex){
			--justInCase;
		}
		Thread.Sleep(50);
	}
}
On the first save, it's fine, but the second time it throws an exception because it's reading the file while the external editor is still writing to it. Also, the event seems to fire twice for each save and the second firing of the event during the second save is OK whereas the first firing will throw the exception. Hopefully that last sentence makes sense :\

rolleyes
Nov 16, 2006

Sometimes you have to roll the hard... two?
I think my dual mode WPF/console attempt may be proving too ambitious.

I'm trying to use a BackgroundWorker and when operating in console mode the ProgressChanged and RunWorkerCompleted event handlers I've subscribed to the events are never triggered and, while the DoWork event handler is triggered, the BackgroundWorker's IsBusy property is never set to false so the parent thread gets stuck in a loop waiting for it to finish.

I wondered if the fact that this is really just a WPF application with its output type set to Console could be causing my events to get swallowed by the WPF event loop or something like that, so I went back to basics. If I simply copy and paste this into a new console application it works as expected. If I copy and paste it into a new WPF application (with the code from Main() transposed into the MainWindow constructor), set the output type to console and run it then I get the same problematic behaviour.

Am I screwed?

epswing
Nov 4, 2003

Soiled Meat
Help, WCF wizards!

The dto objects I've been passing to/from the client/server do not have [DataContract] decorating the classes and do not have [DataMember] decorating the members. What's the point of all those extra lines, because if I just leave those off, all public properties are considered for serialization.

This has worked great for months.

Now, I need to send an object graph with cyclical references. This means (post .NET 3.5) I need to decorate dto classes with [DataContract(IsReference = true)]. So I guess I have to start using [DataContract] and [DataMember] everywhere after all. Adding these attributes, however, causes WCF to spit out a NullReferenceException. I can't seem to find where it happens, I'm beginning to suspect the stack track is bogus and I'm looking in the wrong place.

Here is everything: http://pastebin.com/bpvU1AAq

Canine Blues Arooo
Jan 7, 2008

when you think about it...i'm the first girl you ever spent the night with

Grimey Drawer
I'm looking to use an Access DB to store a small amount of data in a C# program I'm working on, but I'm having issues getting data out of it. Currently, my code looks like so:

code:
        try
            {
                string userInput = inputBox.Text;
                string connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=someDB.accdb";
                OleDbConnection conn = new OleDbConnection(connectionString);
                string sqlQuery = "SELECT * FROM someTable WHERE someColumn='" + userInput + "'";

                OleDbCommand cmd = new OleDbCommand(sqlQuery, conn);
                conn.Open();

                OleDbDataReader reader;
                reader = cmd.ExecuteReader();

                while (reader.Read())
                {

                    Console.Write("This data happens now:  ", reader.GetValue(0), reader.GetValue(1), reader.GetValue(2));

                }

                reader.Close();
                conn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
I've generalized the variables as to not lose anyone. If I'm not mistake, it should print "This data happens now: " followed by the first 3 items in the DB in whatever got matched, however, it's not printing anything out of the DB. I've tried casting them to a string, I've tried fetching the numbers as simply GetInt32 but I can't get anything to actually return. I've checked and double checked the query and it's returning stuff on the Access end of things and at this point, I'm slightly lost.

Suggestions?

Canine Blues Arooo fucked around with this message at 22:13 on Sep 21, 2011

uXs
May 3, 2005

Mark it zero!

Canine Blues Arooo posted:

I'm looking to use an Access DB to store a small amount of data in a C# program I'm working on, but I'm having issues getting data out of it. Currently, my code looks like so:

code:
        try
            {
                string userInput = inputBox.Text;
                string connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=someDB.accdb";
                OleDbConnection conn = new OleDbConnection(connectionString);
                string sqlQuery = "SELECT * FROM someTable WHERE someColumn='" + userInput + "'";

                OleDbCommand cmd = new OleDbCommand(sqlQuery, conn);
                conn.Open();

                OleDbDataReader reader;
                reader = cmd.ExecuteReader();

                while (reader.Read())
                {

                    Console.Write("This data happens now:  ", reader.GetValue(0), reader.GetValue(1), reader.GetValue(2));

                }

                reader.Close();
                conn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
I've generalized the variables as to not lose anyone. If I'm not mistake, it should print "This data happens now: " followed by the first 3 items in the DB in whatever got matched, however, it's not printing anything out of the DB. I've tried casting them to a string, I've tried fetching the numbers as simply GetInt32 but I can't get anything to actually return. I've checked and double checked the query and it's returning stuff on the Access end of things and at this point, I'm slightly lost.

Suggestions?

I'm pretty sure the problem is your Console.Write(...) statement. If you call it like that, it interprets the first parameter as a format string. You should either just concatenate the string ("this data..." + reader.GetValue(0) + ...) or correctly use the format string ("this data... {0} {1} {2}", reader.GetValue(0), ...).

And another thing: while your select statement works, it's a very, very bad idea to do it like that. You should always use parameters instead of concatenating string, to avoid string injection vulnerabilites in your code.

genki
Nov 12, 2003

epswing posted:

Help, WCF wizards!

The dto objects I've been passing to/from the client/server do not have [DataContract] decorating the classes and do not have [DataMember] decorating the members. What's the point of all those extra lines, because if I just leave those off, all public properties are considered for serialization.

This has worked great for months.

Now, I need to send an object graph with cyclical references. This means (post .NET 3.5) I need to decorate dto classes with [DataContract(IsReference = true)]. So I guess I have to start using [DataContract] and [DataMember] everywhere after all. Adding these attributes, however, causes WCF to spit out a NullReferenceException. I can't seem to find where it happens, I'm beginning to suspect the stack track is bogus and I'm looking in the wrong place.

Here is everything: http://pastebin.com/bpvU1AAq
It looks a lot like it has to do with the INotifyPropertyChanged implementation. If you take out all of the Raise calls, does it work as expected?

Also, you don't have a [DataMember] modifier on the IsEdited bool in your BaseDto class.

Finally, I don't really understand how/why you have uneditableProperties. Is that just for the IsEdited property? Can you not just set the Set to protected/private? Or is there a use case where you want the user to be able to change a property but not have the change propagate? Come to think of it, I don't even know why you call RaisePropertyChanged in the IsEdited property, you'll never actually do anything in the handler because it's in the uneditable list...

Sprawl
Nov 21, 2005


I'm a huge retarded sperglord who can't spell, but Starfleet Dental would still take me and I love them for it!

Canine Blues Arooo posted:

I'm looking to use an Access DB to store a small amount of data in a C# program I'm working on, but I'm having issues getting data out of it. Currently, my code looks like so:

code:
        try
            {
                string userInput = inputBox.Text;
                string connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=someDB.accdb";
                OleDbConnection conn = new OleDbConnection(connectionString);
                string sqlQuery = "SELECT * FROM someTable WHERE someColumn='" + userInput + "'";

                OleDbCommand cmd = new OleDbCommand(sqlQuery, conn);
                conn.Open();

                OleDbDataReader reader;
                reader = cmd.ExecuteReader();

                while (reader.Read())
                {

                    Console.Write("This data happens now:  ", reader.GetValue(0), reader.GetValue(1), reader.GetValue(2));

                }

                reader.Close();
                conn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
I've generalized the variables as to not lose anyone. If I'm not mistake, it should print "This data happens now: " followed by the first 3 items in the DB in whatever got matched, however, it's not printing anything out of the DB. I've tried casting them to a string, I've tried fetching the numbers as simply GetInt32 but I can't get anything to actually return. I've checked and double checked the query and it's returning stuff on the Access end of things and at this point, I'm slightly lost.

Suggestions?

You didn't ask it to do anything with the variables.

You should probably parameterized the sqlquery like this the .
code:
                    Console.Write("This data happens now: {0},{1}, {2} ", reader.GetValue(0), reader.GetValue(1), reader.GetValue(2));

Canine Blues Arooo
Jan 7, 2008

when you think about it...i'm the first girl you ever spent the night with

Grimey Drawer

uXs posted:

I'm pretty sure the problem is your Console.Write(...) statement. If you call it like that, it interprets the first parameter as a format string. You should either just concatenate the string ("this data..." + reader.GetValue(0) + ...) or correctly use the format string ("this data... {0} {1} {2}", reader.GetValue(0), ...).

And another thing: while your select statement works, it's a very, very bad idea to do it like that. You should always use parameters instead of concatenating string, to avoid string injection vulnerabilites in your code.

quote:

You should probably parameterized the sqlquery like this

Thanks a lot guys! I would have been looking at that for some time before recognizing that as a mistake. Works perfectly now!

Canine Blues Arooo fucked around with this message at 23:58 on Sep 21, 2011

epswing
Nov 4, 2003

Soiled Meat

genki posted:

It looks a lot like it has to do with the INotifyPropertyChanged implementation. If you take out all of the Raise calls, does it work as expected?

Also, you don't have a [DataMember] modifier on the IsEdited bool in your BaseDto class.

Finally, I don't really understand how/why you have uneditableProperties. Is that just for the IsEdited property? Can you not just set the Set to protected/private? Or is there a use case where you want the user to be able to change a property but not have the change propagate? Come to think of it, I don't even know why you call RaisePropertyChanged in the IsEdited property, you'll never actually do anything in the handler because it's in the uneditable list...

Fair questions.

Adding [DataMember] to IsEdited doesn't help.

The uneditableProperties are those which, when changed, will not set IsEdited to true. I still need such a property to update the UI (via NotifyPropertyChanged("TheProperty")), but I don't consider the change to have "changed the object" by my own definition.

When any other property is set, then IsEdited is set to true, and NotifyPropertyChanged("IsEdited") is called so that I can update the UI to say "this record is unsaved!" If IsEdited wasn't in uneditableProperties then, after a record is saved, setting IsEdited back to false, wouldn't work (BaseDto would consider that a "changed property" and set IsEdited back to true).

If anyone has a better way to do this, I'm open to suggestion. But that's a tangent off my original question.

epswing fucked around with this message at 14:56 on Sep 22, 2011

dwazegek
Feb 11, 2005

WE CAN USE THIS :byodood:

epswing posted:

Help, WCF wizards!...

code:
public event PropertyChangedEventHandler PropertyChanged = delegate { };

protected virtual void NotifyPropertyChanged(String propertyName)
{
     PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
PropertyChanged is null, so when you attempt to call the delegate it explodes in your face. Most (or all) of the DataContractSerializers do some magic fuckery when creating the object and bypass the constructors and initializers completely. Your code relies PropertyChanged to be set to a valid value in the initalizer, but it never runs, so the delegate stays null.

You'll have the same problem again in BaseDto.NotifyPropertyChanged because your hashset will also be null.

Both of these are easily fixed with null checks and/or lazy loading, but you can also use the OnSerializingAttribute, OnSerializedAttribute, OnDeserializingAttribute and OnDeserializedAttribute (all in System.Runtime.Serialization) to mark methods which are run at the appropriate time during (de)serialization.

dwazegek fucked around with this message at 14:57 on Sep 22, 2011

epswing
Nov 4, 2003

Soiled Meat

dwazegek posted:

PropertyChanged is null

dwazegek posted:

magic fuckery

Holy poo poo. :negative:

dwazegek
Feb 11, 2005

WE CAN USE THIS :byodood:
Hmm, I remember having the same issue a while back, but I can't reproduce it by serializing and deserializing the objects locally. So either it's been fixed, or WCF uses the serializers differently than I'm using them.

So maybe it's not the problem you're having at all :v:

Pollyzoid
Nov 2, 2010

GRUUAGH you say?
code:
public event PropertyChangedEventHandler PropertyChanged = delegate { };
Doesn't that initialize PropertyChanged to a non-null value?

VVVVV Right. My .Net is a bit rusty v:shobon:v

Pollyzoid fucked around with this message at 15:22 on Sep 22, 2011

epswing
Nov 4, 2003

Soiled Meat
It does, but after it goes over the wire, it's null. Because the class now has [DataContract], it's not being serialized. Also, the idea of serializing an event doesn't make sense anyways. So this IS necessary:

code:
if (PropertyChanged != null)
    PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
As for the hashset, it's also null after the object goes over the wire. Adding [DataMember] to it solves that.

Much thanks, dwazegek :)

dwazegek
Feb 11, 2005

WE CAN USE THIS :byodood:

epswing posted:

As for the hashset, it's also null after the object goes over the wire. Adding [DataMember] to it solves that.

Now that your hashset is being serialized with the rest of your object, a mischievous person might alter the serialized data and inject a couple of other property names into your list of uneditable properties (or remove them), causing all sorts of weird behavior when events are or aren't raised when they should :tinfoil:

epswing
Nov 4, 2003

Soiled Meat

dwazegek posted:

a mischievous person might inject...

At that point I've got bigger problems :v:

But I'm using https so... :tinfoil:

dwazegek
Feb 11, 2005

WE CAN USE THIS :byodood:
I was thinking more along the lines of a client (deliberately) sending data so that the behavior of your objects is altered. Not some sort of MITM attack.

It's probably not a big deal, but if you don't want anyone to be able to alter the contents of that hashset, you shouldn't give them the means to do so. Just because your client is (probably) using the same objects as the server, doesn't necessarily mean that everyone who will consume your WCF service will do so, so there's really no way of telling what kind of data they'll be sending you.

Of course, you're in a better position to determine if this will be an issue or not.

A MIRACLE
Sep 17, 2007

All right. It's Saturday night; I have no date, a two-liter bottle of Shasta and my all-Rush mix-tape... Let's rock.

Possibly the wrong thread, but I need help with subdomains in IIS7. I want m.mysite.com to redirect to https://www.mysite.com/mobile.aspx. I'm currently getting redirect loop errors. Would appreciate any insight to this problem.

genki
Nov 12, 2003

dwazegek posted:

code:
public event PropertyChangedEventHandler PropertyChanged = delegate { };

protected virtual void NotifyPropertyChanged(String propertyName)
{
     PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
PropertyChanged is null, so when you attempt to call the delegate it explodes in your face. Most (or all) of the DataContractSerializers do some magic fuckery when creating the object and bypass the constructors and initializers completely. Your code relies PropertyChanged to be set to a valid value in the initalizer, but it never runs, so the delegate stays null.

You'll have the same problem again in BaseDto.NotifyPropertyChanged because your hashset will also be null.

Both of these are easily fixed with null checks and/or lazy loading, but you can also use the OnSerializingAttribute, OnSerializedAttribute, OnDeserializingAttribute and OnDeserializedAttribute (all in System.Runtime.Serialization) to mark methods which are run at the appropriate time during (de)serialization.
Oh, of course, events. I forgot how annoying it is to deal with those when going over WCF. Ha.

epswing posted:

The uneditableProperties are those which, when changed, will not set IsEdited to true. I still need such a property to update the UI (via NotifyPropertyChanged("TheProperty")), but I don't consider the change to have "changed the object" by my own definition.

When any other property is set, then IsEdited is set to true, and NotifyPropertyChanged("IsEdited") is called so that I can update the UI to say "this record is unsaved!" If IsEdited wasn't in uneditableProperties then, after a record is saved, setting IsEdited back to false, wouldn't work (BaseDto would consider that a "changed property" and set IsEdited back to true).

If anyone has a better way to do this, I'm open to suggestion. But that's a tangent off my original question.
I think the issue here is that you're putting a UI property into your data object. I'm not sure why you would round trip an edit from the UI to the object then back to the UI, unless you're saying the change comes from outside the UI, but even then, you should have an object state to compare the update with to determine if the edit happened.

Are you tying this object directly to your UI then? And even then, I think it would make more sense to expose the PropertyChanged event so the UI code could test/handle changes, rather than having the object handle it internally to set an edited flag...

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

A MIRACLE posted:

Possibly the wrong thread, but I need help with subdomains in IIS7. I want m.mysite.com to redirect to https://www.mysite.com/mobile.aspx. I'm currently getting redirect loop errors. Would appreciate any insight to this problem.

There's two ways to do this:
1) In IIS: Set up another web project with a header value of m.mysite.com that listens on port 80. Under the home directory property there should be an option to 'redirect to another url' instead of the the 'this is a directory on this computer' option. Enter https://www.mysite.com/mobile.aspx as the destination (you might have to make a folder on your new site that uses a default document, e.g. /mobile instead). Choose whether it's a permanent or temporary redirect. This is taken from memory for iis6 but 7 shouldn't be that different.
2) In code: in the global.asa for your application put code into OnSession_Start or somewhere similar. Read the requested URL; if it's m.mysite.com response.redirect to the other URL.

EDIT-obviously there's more than two ways to do it but that's what I thought of off the top of my head.

A MIRACLE
Sep 17, 2007

All right. It's Saturday night; I have no date, a two-liter bottle of Shasta and my all-Rush mix-tape... Let's rock.

Thanks.

Canine Blues Arooo
Jan 7, 2008

when you think about it...i'm the first girl you ever spent the night with

Grimey Drawer
Issue with Visual Studio 2010 Pro for those of you more seasoned vets of the product.

If I open Visual Studio, close it, put my computer in stand by, wake it up and try to reopen anything in Visual Studio, it's incredibly laggy and nothing gets rendered. The usual start page doesn't show up. If I open a project, switching between a design tab and a coding tab freezes the IDE and if/when I finally get to coding tab, none of the text gets rendered.

This is remedied by restarting my computer, but will pop up again the second I put it in Stand by. Is there a fix for this?

fankey
Aug 31, 2001

Canine Blues Arooo posted:

Issue with Visual Studio 2010 Pro for those of you more seasoned vets of the product.

If I open Visual Studio, close it, put my computer in stand by, wake it up and try to reopen anything in Visual Studio, it's incredibly laggy and nothing gets rendered. The usual start page doesn't show up. If I open a project, switching between a design tab and a coding tab freezes the IDE and if/when I finally get to coding tab, none of the text gets rendered.

This is remedied by restarting my computer, but will pop up again the second I put it in Stand by. Is there a fix for this?
Make sure you have the latest version of your graphics driver. VS2010 uses WPF which leans heavily on the driver. In WPF apps I've written getting the latest driver would sometimes fix issues like these.

Canine Blues Arooo
Jan 7, 2008

when you think about it...i'm the first girl you ever spent the night with

Grimey Drawer

fankey posted:

Make sure you have the latest version of your graphics driver. VS2010 uses WPF which leans heavily on the driver. In WPF apps I've written getting the latest driver would sometimes fix issues like these.

Yeah, I've updated the drivers. Issue persists. I've had issues in the past where putting the computer to sleep and then waking it up causes certain programs to either stop working completely or hang randomly, but I haven't seen it for some time.

I lied, it doesn't even need to sleep. It's just the second time I load VS and every time after that that poo poo hits the fan and effectively dies.

Canine Blues Arooo fucked around with this message at 03:15 on Sep 23, 2011

Che Delilas
Nov 23, 2009
FREE TIBET WEED
There goes my theory that Microsoft deliberately made the Express versions of VS buggy and inconsistent in order to get people to get the full version. (Seriously have you ever tried installing Web Developer Express 2010 on a machine that already has C++ Express 2010 and/or Visual Studio SP1 on it? loving nightmare).

Nurbs
Aug 31, 2001

Three fries short of a happy meal...Whacko!
I'm now working in an environment that uses TFS and VS2010. Previously I just used SVN.

What I want to know, is what the best practice for references is.

With the old way of doing things I'd copy the build output of a referenced project into a 'shared binary' folder in the parent project folder, and then add the reference in the parent project to the 'shared binary' folder. This enabled me to keep specific versions of dlls related to projects with each development cycle.

Should I continue this practice, or switch to project references and use visual studio to get the latest version from tfs?

Canine Blues Arooo
Jan 7, 2008

when you think about it...i'm the first girl you ever spent the night with

Grimey Drawer
Alright, I actually have a question about a thing other than the IDE:

So, as a "You need to learn more about C# and do something kinda of fun" project, I'm building a Modeler for League of Legends, which in itself is unimportant at the moment. However, I'm trying to rebuild the talent trees in a talent tree calculator and after wrestling with a few design options, I decided to just take a screenshot of their talent trees and put panels over the buttons on the PNG thus creating a transparent 'button', but still capable of capturing a click.

However, there are like 60 panels as a result and loading of this tab on the program takes a long time. Like 2 seconds long. In my little world, this seems pretty unacceptable and looks like crap. On top of this, I want to put about 120 labels on this page yet to track current points in talent and max points in talent. I can't imagine this will do the performance any favors. Is there a better way to do this that doesn't bog down the rest of it so badly? If you wish to look at it, it can be found here sans-DB:

http://www.mediafire.com/?objiwiwdurrvqld

Canine Blues Arooo fucked around with this message at 07:11 on Sep 23, 2011

Che Delilas
Nov 23, 2009
FREE TIBET WEED

Canine Blues Arooo posted:

I need an Image Map.

Never used this before and I'm not sure about its performance but it might be worth trying out: ImageMap Control.

Other ideas would be to have a still image (PictureBox control) that handles the Click event, whose behavior would be based on what the mouse coordinates are when clicked (this could be what that ImageMap control does, I don't know).

As for the text, you could look into TextBlock, which is supposedly lighter weight and more appropriate for displaying text on its own than a label. You could also look into Graphics.DrawString, which will let you draw directly onto the canvas. It looks like that would require you to handle a Paint event(a good one to use is probably going to be the control that's displaying your big image). This is probably cheaper than a berjillion text controls.

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

Nurbs posted:

switch to project references and use visual studio to get the latest version from tfs?

This.

Canine Blues Arooo
Jan 7, 2008

when you think about it...i'm the first girl you ever spent the night with

Grimey Drawer

Che Delilas posted:

Never used this before and I'm not sure about its performance but it might be worth trying out: ImageMap Control.

Other ideas would be to have a still image (PictureBox control) that handles the Click event, whose behavior would be based on what the mouse coordinates are when clicked (this could be what that ImageMap control does, I don't know).

As for the text, you could look into TextBlock, which is supposedly lighter weight and more appropriate for displaying text on its own than a label. You could also look into Graphics.DrawString, which will let you draw directly onto the canvas. It looks like that would require you to handle a Paint event(a good one to use is probably going to be the control that's displaying your big image). This is probably cheaper than a berjillion text controls.

This is awesome. I'll be trying this for sure!

subx
Jan 12, 2003

If we hit that bullseye, the rest of the dominoes should fall like a house of cards. Checkmate.
What's the best way display a list of links from whatever data source.

I want a list that displays whatever number of records that are pulled from the query, like:
<li class="someclass"><a href="xxx">name</a> - record number - date modified - <a href="call_to_delete_method">delete record</a></li>

I guess I could do it writing a bunch of HTML markup in the code, but is there a better way of doing this?

wwb
Aug 17, 2004

^^^^^

Web Forms: check out the repeater
MVC: Loop through, make html in the view. If the line item is horrendously compex you might want to consider a partial view to render it.

subx
Jan 12, 2003

If we hit that bullseye, the rest of the dominoes should fall like a house of cards. Checkmate.

wwb posted:

^^^^^

Web Forms: check out the repeater
MVC: Loop through, make html in the view. If the line item is horrendously compex you might want to consider a partial view to render it.

Ah repeater is what I was looking for, thanks. No MVC as this is some lovely inherited code. Hopefully going to get a chance to completely remake the thing in the next month or two.

wwb
Aug 17, 2004

Hehe. Well, if you want to make yourself feel better you can do it MVC style in webforms -- just expose the collection as a protected property and you can access it directly from CodeBehind.

Smugdog Millionaire
Sep 14, 2002

8) Blame Icefrog
I've got a problem with ASPNETMVC DataBinding that I don't understand.
code:
<% Html.BeginForm(new { Controller = "Publishing", Action = "ProcessApprovalForm", id = Model.CenterID }); %>
<% int i = 0; %>
<% foreach (var field in fieldset.Fields) { %>
	<%= Html.TextBox("dontcare", field.Value, new { disabled = "disabled" }) %>
	<%= Html.Hidden("[" + i + "].IsApproved", i % 2 == 0) %>
	<%= Html.Hidden("[" + i + "].ChangeID", field.ID) %>
	<% i += 1; %>
<% } %>
code:
public ViewResult ProcessApprovalForm(int id, List<ChangeApproval> viewmodel)
{ }
code:
public class ChangeApproval
{
	Guid ChangeID { get; set; }
	bool IsApproved { get; set; }
}
This is my form/controller/viewmodel. I wind up with the viewmodel having an entry in the list for every entry it should, but the properties of each element are not databound (they wind up with default values). I think I'm doing it right, but apparently I'm not.
What am I doing wrong?

Adbot
ADBOT LOVES YOU

dwazegek
Feb 11, 2005

WE CAN USE THIS :byodood:

Smugdog Millionaire posted:

What am I doing wrong?

I'm just guessing, but your properties don't have an access modifier, so they default to private, and databinding probably doesn't work on private fields or properties.

  • Locked thread