|
I have a problem with namespaces: I'm working on a project (asp.net, c#), with several layers: -The WebUI (= a website) -A businessrules layer (= a class library) -A datalayer (= a class library) All layers are in seperate projects. There's also a third class library that contains the business objects. The datalayer gets stuff from the database, puts it in a business object, and passes them on to the business layer, which passes it to the WebUI. (All projects are different namespaces as well.) Now the problem I'm having is that for a specific business object, the WebUI layer (sometimes) only recognizes them when I fully qualify it with the namespace. Example: code:
code:
Same problem: when I declare an object of that class (without fully qualifying with the namespace), I can't even use its properties. Intellisense recognizes the object and shows the properties, but compiling tells me that "'WeirdClass' does not contain a definition for 'Id_weirdClass'". When I qualify it, it does work. When I right-click the class, and do "go to definition", it shows me a definition generated "from metadata", that includes all the right properties, and is in the correct namespace. Fully qualifying the class, and then asking for the definition again, shows me exactly the same thing. But still the compiler thinks they're different. I'm stumped. (I could just always name fully name them, but that annoys me.) Any ideas ?
|
# ¿ May 16, 2007 14:40 |
|
|
# ¿ May 19, 2024 11:44 |
|
Oh god yes thank you. I should've known it was something stupid like that. There was a webpage with that same name. (And webpages are classes as well in .NET.) It didn't give the same error for the other object that did work correctly, because while there was also a page for that object, the capitalization was slightly different so there was no conflict there. Thanks ! (And now, weekend ! )
|
# ¿ May 16, 2007 15:26 |
|
I'm doing an ASP.NET project where I have gridviews that show a list of records. These lists don't have to be edited. There are some columns where the value I have in the list is a foreign key. Naturally I want to display something else than a (for the user) meaningless key value. What are some elegant methods of showing the user a value from the other table for each foreign key ? I'm using an objectdatasource as the datasource for the grid. I was able to make a templatecolumn that has a dropdownlist, with another objectdatasource as the datasource, bound to the correct value. But using a dropdownlist in something that can't be edited is rather retarded. I want it to look like all the other columns, but with the value looked up from another table.
|
# ¿ May 24, 2007 11:02 |
|
wwb posted:What is underneath the ObjectDataSource? A typed dataset or a real object? It's an object. I ended up putting the parts of the foreign table I want to view in the object itself. It seemed the easiest way and it's not that much overhead. Perhaps I should make some functions that do get the extra info and some others that don't, to make it more maintainable, I dunno.
|
# ¿ May 29, 2007 19:19 |
|
Dromio posted:I'm having troubles with a session variable: You are doing "string CurrentSite = (string) Session["CurrentSite"];" before you try to write it out, right ?
|
# ¿ Jun 1, 2007 22:25 |
|
Stramit posted:This is the connection string I am using (this does work locally): That AttachDBFilename thing in your connection string looked suspicious to me, so I went to check http://www.connectionstrings.com/?carrier=sqlserver2005. According to that page, the AttachDBFilename=whatever option only works for local SQL servers. So if you have seperate machines for IIS and SQL server (as I suppose you do), your connection string will not work. From your error message, it looks like you're using the .NET sqlconnection, so your connectionstring should probably be something like: "Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;"
|
# ¿ Jun 18, 2007 10:08 |
|
I have a gridview in asp.net 2.0. In this gridview are a whole lot of template columns, containing textboxes for editing. Depending on some variable, I need to be able to set some of the columns (= the textboxes in them) as readonly. I can't do this at design-time, because which columns should be readonly changes sometimes. Is there an easy way to do it ? I think I can by finding the textbox controls upon the rowdatabound event, but that seems rather intensive. I'd like to set the entire column to readonly in one command, just like it's defined at design time in one place. I've also been thinking about just generating the entire grid programmatically (would give me some other bonuses as well, like changing the number of columns), but that feels like it will give a performance hit as well. Anyone here having experience with stuff like this who can give me some tips ?
|
# ¿ Jun 27, 2007 15:13 |
|
Nurbs posted:Nuts, no one else knows why my form mysteriously lost all of its controls, but all the code is still there and the designer file is intact (all of the controls are still declared and instantiated in it)? This sounds close to what happens when you have databound controls and a designed dataset, and then you change the dataset. But in that case you should get an error message I think, and it is solved by just closing the form and opening it again. Other possibility I can think of is also with databound controls, when the column name in a datagrid is the same as something else. But that should also give an error message somewhere. Don't you get a message somewhere ? And does it still compile ? Or run ?
|
# ¿ Jul 9, 2007 22:54 |
|
salithus posted:Why doesn't this work? I think you need to add a dataGridView1.DataBind(); command. (Sidenote: I think you don't need to open or close the connection if you're using a dataAdapter. It doesn't hurt, but it's not needed, the adapter takes care of it.)
|
# ¿ Jul 9, 2007 22:57 |
|
Dromio posted:I hate FileSystemWatcher. It does EXACTLY what it's told to do, which is pretty useless for what most people want it to do. http://www.nirsoft.net/utils/opened_files_view.html This is a utility that lists file in use. It apparently uses windows APIs to do this. Maybe something like this will help ? It's probably a lot more work than just catching exceptions and letting your program wait a bit though.
|
# ¿ Jul 10, 2007 08:58 |
|
salithus posted:dataGridView1.DataBind(); gives me: You're right, that doesn't exist. I'm checking some code here and it seems that I'm using a BindingSource as an intermediate step. Try something like this: BindingSource binding = new BindingSource(); binding.DataSource = yourDataTable; yourDataGridView.DataSource = binding; Failing that, try to give the table an explicit name, bind the bindingsource to the dataset instead of the table, and set binding.DataMember to that tablename. I don't think it's that, but that's the only other difference I'm seeing between my code and yours.
|
# ¿ Jul 10, 2007 13:21 |
|
Munkeymon posted:efb; That shouldn't be necessary. You basically set the datasource to the datatable and that's it. Maybe it's because you didn't define any columns ? I don't know why it doesn't generate them automatically though, it should do that.
|
# ¿ Jul 10, 2007 19:12 |
|
salithus posted:The DataGridView is working now. I realized I hadn't rebooted since last week You may be able to do it by doing the binding with master-detail databinding and using one bindingsource as the source for the other or something like that, instead of handling that in code. Or put the code to fill the grid in a seperate function and call it when the form loads. You're still loading it manually one time when the app starts, but it feels less icky to me than calling the event handler or setting the selected index in code.
|
# ¿ Jul 10, 2007 21:47 |
|
wwb posted:What you do is make a new set of permissions and make that set fully trusted. Instructions are halfway down this page. When I started to make .NET apps, I had problems with the permissions too. So I tried signing them and doing the permissions thing like you're supposed to do. But it's such a huge hassle that I just stopped doing that and now I'm just letting my programs be installed on either the user's PC or on the Citrix servers. In both cases I need some admin to install something, but at least they have experience with installing programs. They don't really with setting the .NET security policy. So if you can avoid it by not running it from network drives, do so. Otherwise you'll have to do the security thing in the link above.
|
# ¿ Jul 14, 2007 18:13 |
|
I have a gridview on a (fairly complicated) aspx page. In the HTML code that it spits out, a starting "div" tag is automatically generated right before the "table" tag. However, a matching closing "div" tag is not generated. Anyone have any idea what can be wrong here ? The missing tag is creating at least one problem and I'm guessing that it could be the cause of another one. Edit: Never mind, found it. See this link for more details. Problem was using SetRenderMethodDelegate to render a gridview with multiple (merged) headers and having an error in the code to do it. Doing the change in the linked comment fixed it. (I'm using the simplified version by Mykola Tarasyuk linked to in another comment there btw.) uXs fucked around with this message at 15:56 on Aug 13, 2007 |
# ¿ Aug 13, 2007 15:17 |
|
I have several gridviews (asp.net) where I need to be able to hide the column with the "delete" button, depending on who is using the app. Right now I'm using this code: this.gridview.Columns[3].Visible = true; I'm really bothered by having to use the column number, it's bound to cause problems down the line when someone adds a column somewhere and suddenly a whole bunch of users can now push the delete button. (I'm probably going to intercept the delete event and do an explicit check to avoid un-authorized deletes, but I still don't like it.) Is there a way to indicate the column to hide with its name or something ?
|
# ¿ Aug 16, 2007 14:14 |
|
For an ASP.NET app, I have the session start event retrieve user information, assign permissions to a User object, and store it in the session state. To check what permissions someone should have, there are several Active Directory groups someone could be in. So I query the AD, and put the groups the user is a member of in a collection. Then, I need to check if the user is in group A and assign according permissions, check for group B and assign permissions, and so on. The question is: what kind of collection do I put the groups in ? A StringCollection seems obvious, but is that fast enough ? Wouldn't a hashtable or something be better ? Or am I worrying too much again about irrelevant issues that aren't issues at all ?
|
# ¿ Aug 21, 2007 17:02 |
|
wwb posted:Probably worrying too much unless you have thousands of groups to check. Ok thanks. I've had a quick look at IPrincipal and Context.User but it doesn't seem too useful for what I'm doing, the security checks are too complicated. Also the project is supposed to be finished at the end of next week so I don't really feel like changing it now. Made me realize (again) that there's still loads of things I don't know about asp.net though. Maybe I should take some overview course somewhere instead of just using google for everything ever.
|
# ¿ Aug 21, 2007 22:17 |
|
havelock posted:You can either do <%= MethodInYourCodeBehindThatReturnsTheStringOfJS() %> in your aspx, or output the whole js block via ClientScript.RegisterClientScriptBlock in your code behind. Regardless of which method you use, I think it's a good idea to put the bulk of your javascript code in a separate .js file, and only put function calls in your aspx or aspx.cs files. Most examples on the internet seem to put all the javascript code in strings in the .cs file, which I think is a hilariously bad idea.
|
# ¿ Sep 5, 2007 16:27 |
|
I am co-developing a fairly large intranet application. There are a number of pages where users do data entry, and obviously I'm doing several checks on the data before committing it. I want the app to show the user in what fields an error was found, so I'm showing a little image next to those fields. They have a tooltip with the error message in it. There's also an area at the top of the page where all the error messages are shown as well. We're using a custom control to handle the display of the images and the error area on top of the page. Unfortunately, because we need to keep track what fields are giving the errors, the actual error checking is done in the aspx.cs-page of every entry form. I don't like this and would prefer it to be done somewhere else, in the objects themselves or a business rules tier or whatever. The error checking would work just fine there, but I have no idea what the best way would be to store in what fields the errors have occured. Anyone here has a brilliant idea that doesn't involve storing too much extra data on what entry field correlates with what property of a business object ?
|
# ¿ Sep 21, 2007 15:08 |
|
Roope posted:What is the recommended naming scheme for Windows Forms controls? Is the Hungarian notation still being used? I haven't done Forms programming for ages and don't have a clue how to give meaningful and short names to monsters like toolStripMenuItem1. The code looks like disgusting mess with the long default names (ButtonMenuFileStripContainerItemViewBlahBlahObjectEtc123). Normally I keep the control type in front, like TextBoxTitle or DropDownListMonth or whatever. But the names of controls in a menu or statusbar become way too long that way, so I shorten those to, for example, MenuMain and MenuEdit. Or perhaps MenuItemMain and MenuItemEdit, I dunno. Definitely not the ridiculously long default names though. uXs fucked around with this message at 13:23 on Sep 22, 2007 |
# ¿ Sep 22, 2007 13:17 |
|
wwb posted:We use a variety of solutions depending on nature of the application. The large, industrial strength stuff flies off a home-brewed quasi ORM solution, largely for the same reasons lightbulbsun states. Biggest kicker is that most of the new, neato, augo-generated ORM solutions pretty much demand a 1-to-1 mapping of db to public properties, which might not make sense in some scenarios. I used datasets when I started out with .NET because it seemed like the obvious solution. Lately we've been using objects to pass data around with, and I like it a lot. I still use datasets in the latest project though, to be able to bind them to datagrids for very quick and dirty reporting. They're also easy to export to Excel for example. Using objects for that would be a lot slower to write. With datasets it's just basically writing a query, putting it in a dataset, and binding it to a grid.
|
# ¿ Oct 21, 2007 21:06 |
|
FinkieMcGee posted:C#/ASP.NET Caching question, as I'm a rookie and I'm trying to understand what the hell is going on. The way I used caching in this app I made is the following: everything (*) I read from the database is put in custom objects and generic lists of those objects. They got bound to dropdownlists and what have you with objectdatasources. Now for some dropdownlists that I needed a lot, I created a cache object that had functions to retrieve the lists from the cache (or retrieved them from the database and put them in the cache first if it didn't exist yet or was expired.) So where normally it would ask some class to retrieve a list from the database, for those lists it would ask my cache class to retrieve the list from the cache. I don't really know if that improved performance really, but it was a neat thing to do Now I'm not really clear on how you're doing it. You're storing each table as a table in a Dictionary, but then what do you do with that Dictionary ? Are you putting that in the cache and retrieving it all the time ? (*: There were, naturally, exceptions on this.) Edit: ^^ Wait. That Dictionary is just in some static class ? I'm not 100% sure, but I think it's possible that the Dictionary is being recreated for every single call to the webserver. I doubt that it's persisted through postbacks, let alone sessions. uXs fucked around with this message at 00:19 on Mar 19, 2008 |
# ¿ Mar 18, 2008 23:46 |
|
LetoAtreides posted:alright, here it is. Thing is, if I put cardgen() once outside the main method and then once inside the main method, it'll output two different cards I think the problem is that you're making a new Random object each time you call your method. If you make 2 of them at practically the same instant, you can get the same "random" value. The following would probably work better: code:
code:
Code not tested in any way. Also I don't know how thread-safe this is, but I don't think you care.
|
# ¿ Mar 22, 2008 12:55 |
|
notflipmo posted:C# + .NET 3.5 Two other options to work with XML if you're not hell-bent on doing it really manually: * XmlSerializer. Very easy to do. You just put some attributes on a class, give the command to deserialize, and the file gets read and put into an object where you can do whatever. * Linq to XML. Never used it, but it should work.
|
# ¿ Mar 24, 2008 23:11 |
|
ray2k posted:You could write a Visual Studio Addin that scans for those common scenarios and prevents a compile from passing if they are found. But it would be far more effort than, you know, remembering to actually dispose of things correctly the first time. Can't you do this sort of thing in something like FxCop ? I've never used it or seen it closely, but I'm fairly sure it's a tool that can check code for compliance to all sorts of rules. Not closing connections seems like right up its alley. If you have a Team Foundation Server you could even make compliance required before you're allowed to check in code.
|
# ¿ Mar 27, 2008 09:42 |
|
zero87t posted:What does DataBind() do? It binds data. Maybe the confusion here is because you only have to do it in ASP.NET, and not in WinForms. Or maybe it's the other way around, I always forget.
|
# ¿ Apr 3, 2008 08:26 |
|
Richard Noggin posted:I don't believe there's an option to do that in the GD control panel. It would help if you told us what your co-worker is trying to do. If he's trying to read what files are on the webserver, that sounds horribly insecure and I'm not in the least surprised that it's not allowed.
|
# ¿ Apr 9, 2008 16:56 |
|
Richard Noggin posted:This will be used to display random images from a directory on a web site. The directory is a subdirectory of the site (e.g. /images). Is there any way you can keep a list of files, so you don't have to read the directory content ? It might be easier to do that than to gently caress around with permission problems. Those are hard enough when you have full control over the server, it will be even harder when you don't.
|
# ¿ Apr 10, 2008 08:23 |
|
Also, there is no difference between the two. The compiler should compile it exactly the same. The first method is just easier to write and read (once you know what it does.)
|
# ¿ Apr 13, 2008 12:38 |
|
cadmium posted:Here's a question, I'm trying to use XmlSerializer on a class hierarchy. I'm trying to produce some simple xml for a 3rd party api. What I'm getting is close, but the XmlSerializer insists on junking it up with xsi/namespace crap: Weird. When I try to serialize things, it just puts <?xml version="1.0" encoding="utf-8"?> and <RootElementNameHere xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> at the top, and that's it. Can you post the code you use to serialize, and the class you're serializing ?
|
# ¿ Apr 16, 2008 19:18 |
|
Uziel posted:This is the error I get: Is "pkgcode" supposed to be in quotes ? It looks like it should be a variable and you accidently put quotes around it.
|
# ¿ Apr 18, 2008 18:16 |
|
Jethro posted:From what I can tell, "pkgcode" is a string corresponding the name of the parameter in the request, i.e. blah.aspx?pkgcode=101, and the first string is the name of the parameter in the select query. "FormViewDataSource.SelectParameters.Add(New QueryStringParameter("pkgcode", "pkgcode"))" will send "SELECT PackageName, Channel, PackageCode FROM DACPkgs WHERE Pkgcode = 'pkgcode'" to the database. "FormViewDataSource.SelectParameters.Add(New QueryStringParameter("pkgcode", pkgcode))" will give you, for example, "SELECT PackageName, Channel, PackageCode FROM DACPkgs WHERE Pkgcode = 5", which is probably what you want.
|
# ¿ Apr 19, 2008 16:55 |
|
MORE CURLY FRIES posted:How do I get a C# application to publish with an extra file dependency? There's a "Copy to output directory" property for files, maybe that'll work.
|
# ¿ Apr 21, 2008 09:04 |
|
Z-Bo posted:Has anyone here leveraged XAML this way? This post is pretty hilarious if you've just read the "corporate buzzwords" rant thread in GBS.
|
# ¿ Apr 28, 2008 11:47 |
|
poopiehead posted:It's as if every time it hits yield return, it adds the returned object to an enumerable and then at the end returns the whole thing. Except that one of the neat things about yield is that it doesn't create intermediary, temporary lists. If you call something that uses yield, and you only iterate through the X first items, only those X items will be created in the yielding function. It does not create the entire list first and then return it, it just creates the ones you need, one item at a time, when you need that item. So, saying that it's like making an enumerable first and then returning it may look like a good way of explaining it, but unfortunately it's wrong.
|
# ¿ Jun 4, 2008 16:11 |
|
Linq to SQL, interfaces, ... question: I'm getting a generic list of objects of type A from a database, with a function that first performs a Linq query and then does a queryResult.ToList() to return "List<A>". A implements the interface IA. What I actually want to do is instead of returning a List<A>, is to return a List<IA>. (I want to use that list in other functions that should accept any List<IA>.) But then I get errors like "Cannot implicitly convert type 'A' to 'IA' at ..." Any ideas ?
|
# ¿ Jun 20, 2008 11:13 |
|
dwazegek posted:queryResult.Cast<IA>().ToList() Follow-up question: I have the following interface/classes: code:
code:
code:
In the following code however, everything throws an InvalidCastException, and I don't know why. It seems that the Cast() function can't work with user-defined conversions or something. Any ideas ? code:
uXs fucked around with this message at 10:25 on Jul 9, 2008 |
# ¿ Jul 9, 2008 10:23 |
|
dwazegek posted:Casting is not the same as an explicit conversion, even though the syntax is identical. Cool, thanks. Having to do stuff like that makes me feel that there is probably something wrong with the design, but whatever. Thanks :-)
|
# ¿ Jul 9, 2008 20:28 |
|
|
# ¿ May 19, 2024 11:44 |
|
MORE CURLY FRIES posted:Yeah, getting the info out of the database isn't the issue, it's the live updating of the page as the slower responses come back to the user. I'd try splitting this up: one page that is shown to the user, and three that are basically just XML with the data. Using Javascript and a HttpRequest thingie, you can do the requests for data, and attach a callback function to each request. When the data is ready, use Javascript to show it to the user. This is basically Ajax, but done in a rather manual way.
|
# ¿ Jul 16, 2008 10:03 |