|
Victor posted:Mods: please fix the post icon. I tend to just use a unique class name. It's ugly, but it works.
|
# ¿ Jan 4, 2007 20:39 |
|
|
# ¿ May 19, 2024 12:56 |
|
Sorry this is going to be long: I'm getting a weird error in an ASP .NET 2.0 page.... This only happens in IE7. Fine in firefox and IE6. error posted:Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation. I have a repeater control with a bunch of child controls in the item template: code:
code:
I was able to avoid the problem by getting rid of the useless postback that shouldn't have been there in the first place and just making it a link. code:
|
# ¿ Jan 4, 2007 21:02 |
|
superb0wr posted:Anybody know what those [SquareBracket] directives or whatever you can use in c# are called, and if its possible to write custom ones? Like [STAThread] or [WebMethod]? They're called Attributes and they're accessible through Reflection. I've never used them before, but this looks like a good explanation:
|
# ¿ Jan 4, 2007 23:16 |
|
csammis posted:String.IsNullOrEmpty() Isn't there some kind of bug associated with that function? It seems so convenient but I've been nervous to use it since I heard it doesn't always work.
|
# ¿ Jan 5, 2007 22:27 |
|
Victor posted:The bug has to do with JITing code in loops; it isn't a problem with String.IsNullOrEmpty itself. If you don't use the method in loops, you're golden, otherwise you might want to look up the bug details. Thanks. good to know. I'll have to look up the details.
|
# ¿ Jan 5, 2007 22:46 |
|
Heffer posted:Here's example #1 of how things could go wrong. Say you have a table that contains a field for an ID number (2 bytes) a date (8 bytes) and the file itself (32,000 bytes). The rows for the table ordinarily get stored consecutively on the disk, and the database only keeps track of where the first row is, apart from indexes and such. Wouldn't this be solved by having an an index on the date field? Then it just has to read through the index which is something like 10 bytes per entry. If you're already inserting large files into the database, you're probably not worried about the overhead of an index. I can see where example 2 makes sense though.
|
# ¿ Jan 12, 2007 00:16 |
|
In C# ASP .NET 2.0, is there a way to get a mime type from a file extension. I've seen one way by searching through the registry, but I was hoping there was a less hackish way.... Any ideas?
|
# ¿ Jan 12, 2007 00:36 |
|
Grid Commander posted:Yes, figure out what each file formats' header is. Most binary files have special header at the top of the file. It will be different for different file types. It will be stored at a different location for each file type. It will likely be stored in the first 12 bytes of the file. Thanks for the info. What I, and I'm assuming Grid Commander, are looking for is to return the same Content-Type header as the web server would for a given file. Servers just look up extensions in a table they have and return the associated content type. I probably didn't make that clear in the original question. In my case, what I'm trying to do is dynamically serve up files through a server side script. I'll know the extension that the file originally had, so I'd like to get the content type from that. I can store the content type when the files are uploaded, but would rather avoid it. poopiehead fucked around with this message at 07:55 on Jan 13, 2007 |
# ¿ Jan 13, 2007 07:51 |
|
Frank Butcher posted:I'm thinking of starting to programme in C# instead of VB. I have a large VB project and was wondering if it's possible to begin writing new classes (or even forms) in C# within this project? I heard that all code compiles the same so I was wondering if it's possible. Besides what was already mentioned, there are a bunch of guidelines that you should follow to make sure that they will work across all languages. This has nothing to do with internal code, only externally accessible things. The most important thing would be to not have identifiers in C# differ only by case, because VB wouldn't be able to make sense of it. I couldn't find a good link but found this from an old class web page. guidelines
|
# ¿ Jan 16, 2007 04:47 |
|
Mind Riot posted:Reposting from another thread: I can see two ways that are pretty much the same. 1) Add a TryLogin event to the login control. The implementing page can add a delegate to the event. When a login is attempted, fire the event and pass a reference to the login control as a parameter. Then the delegate can set a public IsLoggedIn or LoggedInUerId property when it gets called. 2) Create a delegate. Something with a signature like "bool TryLogin(string username,string pass)". Then have a public property of the type of that delegate. The implementing page can set the property. When a user attempts to log in, use the provided delegate to perform the login.
|
# ¿ Jan 16, 2007 07:38 |
|
wwb posted:^^^Those are basically the same thing. The event is essentially a specifically formed delegate. poopiehead posted:I can see two ways that are pretty much the same.
|
# ¿ Jan 16, 2007 17:01 |
|
Grid Commander posted:On a side note -- I think it might be possible to host php on IIS? There might even be a php variant that targets MSIL. I didn't research that much though, so I can't say for sure. It can definitely be installed on IIS. http://www.php.net/downloads.php edit: the above link is just to run on windows. The cgi version is what runs on IIS: http://us2.php.net/security.cgi-bin poopiehead fucked around with this message at 21:16 on Jan 18, 2007 |
# ¿ Jan 18, 2007 09:05 |
|
Essential posted:Hey all I have some very basic Asp.net questions (I just started getting into Asp.net but I have a vb6/vb.net 2005 background). I have been using vs 2005 for the last 2 years or so. Are you familiar with HTML? I've never seen an editor for web pages that works like the VS Form Designer and actually works well.
|
# ¿ Jan 19, 2007 08:01 |
|
Essential posted:Also I must be a real jerk to not realize I would need html/css for formatting I think MS did intend for people to use the designer, especialy coming from an app dev point of view. So it wasn't a ridiculous assumption. You definitely need to know HTML to work with it effectively, though. I like w3schools for quick overviews. Here's a tutorial I'd definitely try to get to the point where I can lay out a simple flat web page in html before diving into asp .net. Most introductory asp .net stuff assumes programming experience, which you do have, and html experience, which you will.
|
# ¿ Jan 19, 2007 09:17 |
|
pliable posted:That didn't work, since DocumentElement is a property . Is it a method in Visual Basic? I'm not very familiar with VB, so. It should be an empty string. code:
code:
|
# ¿ Jan 19, 2007 21:06 |
|
Jethro posted:Book Question: Progamming C# might be a bit tough with no OO experience. I've heard good things about(but have not read myself) Learning C# for less OOP experienced people. poopiehead fucked around with this message at 20:19 on Jan 22, 2007 |
# ¿ Jan 22, 2007 19:42 |
|
I'm trying to make the defaultbutton for a textbox be a linkbutton. Sounds simple enough, but not really. There seems to be a bug(or at least weird feature) in ASP .NET that makes this not possible on firefox. Looking at their JS, they try to use the defaultbutton's click() method which firefox doesn't define for anchor tags. This script fixes it so that there is a click method. code:
Is there anything wrong with this besides the fact that if MS changes their LinkButton Control, then my code might die?
|
# ¿ Jan 23, 2007 23:28 |
|
Goonamatic posted:I just use my function Thanks for that. I think I'll end up using this cases when I don't want to use a Panel to set the DefaultButton because it renders a div tag that may mess with layout. My current problem is with LinkButton though, which renders as something like this: <a href="java script:__doPostBack('ct100_btn','')">Go</a> MS's implementation of DefaultButton in 2.0 lets you choose a linkbutton as the default button but it tries to use the click() method to click it. That's fine in IE, but firefox doesn't have a click() method on the <a> tag object.
|
# ¿ Jan 24, 2007 18:19 |
|
havelock posted:Unless I missed something, that string is static. There's no reason not to just use a literal for it. Even if you break it up on multiple lines. Also using @"" works great for those situations because then you can read your javascript relatively easily. code:
|
# ¿ Jan 24, 2007 18:46 |
|
marcan posted:C# newb here (I've used C, Java, and others, but this is the first time I mess with C#) You also might find the Abort method of the Thread class. When you start the thread, save the object and on FormClosing, call Abort. (never used the abort method myself but it looks like what you need)
|
# ¿ Jan 25, 2007 09:10 |
|
Essential posted:So would you typically set up your session objects in the Global.asax file? No need. Just do: Session["asdadad"] = anyobject; in any page. If you end up keeping things all in the same page, then Viewstate is better as long as you're not trying to save huge things. I generally use Viewstate and a bunch of panels based on what I want to display in these kinds of cases, though the WizardView is probably better. I just never used it before.
|
# ¿ Jan 29, 2007 06:19 |
|
Essential posted:I want to see if I get this right. You might have, say a home page panel, a products page panel and a contact us panel and just load/show whatever panel based on where the user wants to go? And all these panels are on one page? If that's the case does this make for a faster site? Not exactly. Home and products would be separate pages. My products page would most likely accept a product ID in the query string from a normal link on another page. If I was using something other than a link, like a select box to get to the product page, then I would use Response.Redirect() to get to the product page. I'm having trouble coming up with a good example for a single page that could be multiple page...... Let's assume you have a mortgage calculator. The first page is a form to fill out your financial stuff and the second is to display some graphs or something of ways to pay off your mortgage or whatever. Assume the form is really long, so it wouldn't look good if you just put the forms and graphs on the same page. I'll probably have two panels. One for the form and one for the graphs. Initially, the graphs are not visible and the form is visible. On postback, I do processing and then toggle the visibility of each panel so that only the graphs are showing. quote:The other thing they want is in depth knowledge of asp.net 2.0 page lifecycle. Are they refereing to "state" issues or page_init, page_load type stuff? Any ideas? They most likelye mean page_init, page_load etc. They also might be interested in if you know the order in which child controls get their events fired(wrt to parents) or how master pages fit into the picture.
|
# ¿ Jan 29, 2007 06:58 |
|
Essential posted:Referring to master pages though, you mean how a master page is used to set up a consistent default look, with respect to header, footer and menu navigation (as well as anything else you want to set up). Then you add content pages that use the master page as the parent page and add your page specific interface into the ContentControl? (I think it's called ContentControl) Exactly, but I meant the order in which events fire on the master page. Like does the load of the master page or the page get called first. And then also do the load events of child controls get called before or after their parents' loads. I'm not sure of the answer without looking it up but figured that may be a question they'd ask when they specifically mentioned they want you to already know the page lifecyle.
|
# ¿ Jan 29, 2007 07:28 |
|
Victor posted:These are considered tips and are very welcome as far as I'm concerned. Just a thought: if they're preceded by Tip: or something like that, a script could be written to aggregate them. Or even better, put them inside [tip][/tip] tags. That way a script would only grab the tips and not the rest of the post, like Fiend's edit.
|
# ¿ Jan 29, 2007 20:43 |
|
Nurbs posted:If I use an sqlcommand object and add parameters, how can I make the value of a parameter null? I want to update a field to null or insert nothing (and I have a fixed amount of data, I don't want to dynamically build the command text) Just add a null value. I forget the exact syntax but: code:
code:
|
# ¿ Feb 3, 2007 08:15 |
|
Nurbs posted:Thanks. try adding System.DBNull.Value. (again I'm probably off a bit with the spelling/name.). sqlCommand.Parameters.AddWithValue("@notes", System.DBNull.Value);
|
# ¿ Feb 3, 2007 16:54 |
|
Fiend posted:I'm using C# & VS 2005. 2 options I can think of. both pretty much suck. 1. Use XSL which supports sorting to make a new XML document. 2. Implement a sorting algorithm on your own and just move around the nodes.
|
# ¿ Feb 6, 2007 20:22 |
|
Heffer posted:It could be a fixed with column. Depending on your database, that could mean it pushed out a lot of blank characters after your text to fill it up to the fixed width. Just trim it and forget about it. Just to clarify..... If you have a column of type char(x), it is always x characters long with extra whitespace to reach that size. varchar(x) will only be as long as it needs to be up to length x. (There are other fixed with types also but it sounds like you're dealing with char)
|
# ¿ Feb 6, 2007 21:30 |
|
The reason it's easy to get from a file upload control is that the browser sends a mime type as part of the http post when you fill in a file form field. So that's not really available in a .NET application. This is what I'm using. The second function is the only one that's actually necessary. The other was just to cache the results. code:
poopiehead fucked around with this message at 00:32 on Feb 8, 2007 |
# ¿ Feb 8, 2007 00:28 |
|
This is probably more of a haus of tech support question, but people here are more likely to know. How do you uninstall an add-in from VS .NET 2005? The VMWare add-in, which I don't use doesn't like Vista, so I need to get rid of it. I know I can hold the left shift button when starting up to have it not load, but I was hoping to just make it go away.
|
# ¿ Feb 8, 2007 00:57 |
|
shelleycat posted:Could it be that someInt++ is of type int. int is not a boolean, and cannot be equated to boolean in C#. (someInt++ == 0) would be a boolean result. Victor already answered the actual question, but to answer yours. The ternary operator requires that the 1st operand is a boolean and that the second two operands are of the same type of each other, but not necessarily the same as the first.
|
# ¿ Feb 14, 2007 23:33 |
|
With C#, is there a way to listen on a port that's already being listened to by a windows service or something? It's a long story, but I wrote a program to run on a VM to let it work as a proxy for the host machine to talk to the VPN. It works perfectly for a bunch of ports, but if I need to pass on RPC port(TCP 135) to a machine on the VPN, it won't let me listen because windows is already listening on the port. Now is there a way to intercept those packets when they come in over a certain IP? So I want to be able to listen on 169.254.80.32:135 without otherwise interfering with windows. (that IP is a direct connection between the host and vm). Is that possible? EDIT: that's probably a security concern and impossible....... How about anyone know a way to switch the port before it gets there, either on the way out of the host or into the VM? poopiehead fucked around with this message at 02:29 on Feb 23, 2007 |
# ¿ Feb 23, 2007 01:21 |
|
^^^^^Do you mean something like this:code:
|
# ¿ Feb 23, 2007 16:41 |
|
wwb posted:I have some experience with using the where predicates. And, in most cases, you are probably better off just using (or inheriting) from a List<IWhatever> because that is what you actually want. But then you lose the advantage of the class being generic. If you don't want a generic class, then that makes sense. But, let's say you want a list that can be cloned. You have to make sure the entries are ICloneable, and then use the Clone() method of the items in your Clone() method. But if you just do CloneableList : List<ICloneable>, then you can't use it as a generic list. You have to a lot of casting and can't guarantee that everything in the list is the same type. poopiehead fucked around with this message at 17:07 on Feb 23, 2007 |
# ¿ Feb 23, 2007 17:04 |
|
rotor posted:This idea never occurred to me, as I've never used other languages in my c# apps. Can I use the BigInteger code from J#? And if so, how much lard will this add to the binary? The binary just has MSIL for any language, so there shouldn't be any extra lard for using a different language.
|
# ¿ Mar 1, 2007 19:13 |
|
I don't use Express, but it might have this functionality. In SQL Server Management Sudio, I right click on a database, then choose tasks, then generate scripts and you can script at least the tables and procedures. I don't think you can get data that way though. There is an export data wizard that can make a flat file, that you could then probably import to GoDaddy
|
# ¿ Mar 6, 2007 23:34 |
|
Yaksha posted:Where is the export wizard? This might not be included on the express version.
|
# ¿ Mar 7, 2007 21:17 |
|
Yaksha posted:I do have a "Generate Scripts" option, however, this is what I did earlier and it only seemed to export the table structure, not the data. (I don't have import/export). That sounds about right. Generate Scripts can do stored procedures and tables, etc, but not the data in the tables. If you don't have an export option in that menu, you may be screwed(at least using this application)
|
# ¿ Mar 7, 2007 21:58 |
|
You can just read through the stream. When you see one of the nodes you're concerned with, figure out which one they are and then get the text. edit: this is what I mean: code:
That said, a DOM probably won't really hurt you with such tiny XML. poopiehead fucked around with this message at 16:39 on Mar 8, 2007 |
# ¿ Mar 8, 2007 16:22 |
|
|
# ¿ May 19, 2024 12:56 |
|
Qaz Kwaz posted:Not sure what these other guys used, but when learning ASP.Net I found the Wrox Professional ASP.Net 2.0 book to be very solid. You should give it a look. That book was very helpful to me when I had to learn ASP .NET. It's not perfect, but it's pretty drat good. As far as data binding goes, as someone said above, in almost every case, I've gotten by with just assigning a collection of my business objects to the datasource property of the databound control.
|
# ¿ Mar 19, 2007 06:45 |