Nvm - got a solution on the ever-helpful http://forums.asp.net - changing the exposed control type to PlaceHolder instead of Control fixed it. Good enough solution.
spazzman
Posts
-
How do I make a server control with 2 child controls, AND design support? [modified] -
How do I make a server control with 2 child controls, AND design support? [modified]I need to make a server control for controlling layout on my page. For various reasons, I don't want to use a master template, and the easiest approach is to make a server control which exposes two child controls. The content on my webpage will be added to these two exposed child controls, which in turn will be rendered surrounding by the layout HTML I need. Everything works fine, except I have no design-time support for it. In other words, I can compile the code, but I have no intellisense on in, which is a major inconvience. I've tried adding the standard attributes to the exposed properties, but I keep getting the "Content is not allowed between the opening and closing tags..." error. Can anyone tell me which attributes I need to add to my control class or its properties in order to get Visual Studio 2005 intellisense to work with the TopContent and BottomContent properties? Thanks! // ###################################### // what the useage should look like : // ###################################### <cc:LayoutTemplate runat="server"> <TopContent> </TopContent> <BottomContent> </BottomContent> </cc:LayoutTemplate> // ###################################### // control definition : // ###################################### public class LayoutTemplate : System.Web.UI.WebControls.WebControl, INamingContainer, IPostBackDataHandler, IPostBackEventHandler { #region FIELDS private Control _topContent; private Control _bottomContent; #endregion #region PROPERTIES [PersistenceMode(PersistenceMode.InnerDefaultProperty), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] public Control TopContent { get { return _topContent; } } [PersistenceMode(PersistenceMode.InnerDefaultProperty), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] public Control BottomContent; { get { return _bottomContent; } } #endregion #region CTORS public LayoutTemplate( ) : base(HtmlTextWriterTag.Div) { _toptContent = new Control(); _bottomContent = new Control(); this.Con
-
How do I execute an Ascii-formatted script from my code?Eek. I can't believe I missed that :( Thanks for pointing it out to me!
-
How do I execute an Ascii-formatted script from my code?I want to create some database objects (tables, stored procedures etc) from a TSQL script. The script is stored in an ASCII txt file, and was generated using the MS SQL Manager's "Generate SQL script" option. This is my problem : the script file contains formatting (line breaks, tabs etc), TSQL comments and so forth. If I simply load the contents of the script file into a string variable, and execute this from my C# code the way I would any ad-hoc SQL command, the ASCII-text formatting breaks the SQL. For example, "SELECT * FROM MyTable;" now becomes "SELECT *\r\nFROM MyTable;" This is not valid SQL, and an exception is thrown. If I parse out all the ASCII formatting (and TSQL comments etc), I can execute a very large TSQL script file as an adhoc SQL command with no errors. This is great, except that my stored procedures now lose all their nice formatting and comments, making them difficult to read. So ... is there some way to execute an ASCII-formatted TSQL script from C# code without having to strip all the ASCII formatting out? Thanks in advance!
-
Security exception when accessing db from dllHi. I've got an asp.net application being hosted on some commercial hosting server. In my project I have a dll (also my code) that contains all my database accessing routines. My database is part of the same hosting domain. When I try to access the database using the dll, I get this exception : --------------------------------------------- Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file. Exception Details: System.Security.SecurityException: Request failed. --------------------------------------------- If I copy the database accessing code from the dll to an aspx page in my project, it works fine. Clearly I'm not allowed to access the db using this dll. The hosting site uses medium-level .Net security privelages, if that helps. Does anyone know a way around this problem? I tried making my Dll strongly named, but that made it even worse - a strongly named dll can't even be linked to without throwing an exception. I've had the same problem with Bytefx.net's strongly-named MySQL database accessing dll - merely linking to that dll throws an exception. Any help would be greatly appreciated. - Shukri
-
bizarre datetime parse error ...I'm using System.IO.Directory.GetCreationTime(folderName) to get the creation date of a folder, but it throws an ArgumentOutOfRangeException with the message "Specified argument was out of the range of valid values. Parameter name: Not a valid Win32 FileTime." The folder in question is on a CDR that was burnt on a PC with a different datetime locale. Why is it that Windows Explorer can display the datetime of the folder without any problems, but the .net framework chokes on it? Does System.IO.Directory require some sort of CultureInfo to parse dates? If so, where do I specify this? Thanks in advance
-
Looking for an ASP.Net developer for Open source projectI've got two open source projects running at the moment - just me on both of them. One is a reusable security/user management component, the other is an bookmark manager. In both cases, I've more or less finished up the data and business layer stuff without hassles .... but I'm stuck on the web user interface. My web design isnt the strongest, and I'd like to find someone who can a) take over the web UI side of my projects, and hopefully b) share ideas with. I prefer having at least two heads on a project - helps to keep things tighter. If anyone is interested, drop me a line at oxygene@worldonline.dk. You should be: a) good at asp.net specifically b) reasonably good at web styling (CSS etc) c) in possession of at least some undertanding for OO concepts (I'll be handling most of the "backend" stuff, but you need to be able to code up against my stuff easily enough) Appreciating open source ideals is definitely a bonus. Hope to hear from someone out there :) Shukri
-
how can I suppress browser detection when rendering an asp.net control?hey, thanks a lot! some good info in there. I like the fact that you are proposing several solutions. Gives me something to choose from. I dont want to use the Web.config solution because I want my controls to be proper drag-and-drop, and having to modify the web.config kinda breaks that. Besides, if the default asp.net controls work in all browsers, why can't mine? Thanks again!:cool:
-
how can I suppress browser detection when rendering an asp.net control?I've written a custom server control. In the render method I use the HtmlTextWriter object to render all my HTML. Fine. It works great in Internet Explorer, but when I view the control in Firefox, most of the CSS stuff is removed by the HTML rendering process. If I save the IE output as a static HTML page and view that in Firefox, it works fine, so obviously the CSS stuff I wrote works for both IE and Firefox. The Asp.net rendering process just doesn't want to output all the style stuff when it encounters Firefox. After searching the web, I found a "solution" to this problem : add this the web.config ... tagwriter=System.Web.UI.HtmlTextWriter Asp.net then ignores the browser and just dumps out the HTML. That works fine for both IE and Firefox. My problem is, I dont want to have to edit the web.config file just to make a control render properly. It seems like overkill. I know that if I use Microsoft's own controls, like buttons or textfields, they work just fine in Firefox, no web.config editting required. I would like to have the same for my own server controls. Is there anyway I can force this ignoring of browser, from _within_ my server control? It has to be something I set in my code, not something I set in the web.config or machine.config. Any help would be greatly appreciated.
-
looking for .Net class lib to edit mp3 and ogg tagshey - does anyone know where I can find a class library (ideally in C# but any .Net classes will do) which allow me to edit tags on MP3s and Oggs. I need ID3.v2 support for the mp3 tags. Thanks in advance!
-
why do my querystrings persist?I have a simple web application where I navigate to some page which has a form on it - I pass some values to the page using querystrings, and the page then renders a form. But when I submit the form, I see that the querystring values are still there. Anyone know how I can stop this? Thanks!
-
C-style altenative to MS ASP.Net web control library?Actually, it was a serious question - I dont see how you could interpret it as trolling. If you dont understand these things, it's okay. Just sit at the back and dont get in the way.
-
C-style altenative to MS ASP.Net web control library?I'm a Windows application developer, trying to get into some web development. I'm really into using good OO design. Is it just me, or is ASP.Net still too "scripty" and "page-centric"? With ASP 3.0 you wrote your stuff as webpages - embedded server-side scripts in what was essentially an HTML document processed on the server. With ASP.Net I thought we'd have the ability to write web applications which at the class level functioned like a Windows application - a core parent application which responded to user input, instantiating and rendering various classes from a namespace hierarchy. I also thought that web controls would behave the same as Windows controls - unlimited levels of nesting, bulletproof eventhandling etc etc. The more I get into ASP.Net, the more I realize that it started off as a great idea, but it wasnt really fully implemented. For example, you can't really write all your code in the "codebehind" section - you still have to write some HTML or ASP.HTML, where you don't get type safety or the ability to have the compiler catch mistakes. Hence you still have to find a some errors at runtime, instead of compile time. Bad. Also, user controls in ASP.Net arent as powerful as they could have been. Web controls dont always expose all the HTML properties that the final rendered HTML elements support. And they dont compile into a DLL. And they dont really nest under other webcontrols that well (you can lose events for example). Does anyone know of an alternative to MS' ASP.Net control library? Something that a) can be used entirely in codebehind b) is based entirely on classes in a namespace hierarchy, not "classes embedded in aspx pages". c) can be compiled into a DLL and thus deployed in other web applications without having to copy over various loose source files. d) that implements more properties of the final rendered HTML elements. In short, I want to code a web application the same way I would code a C-style application. It should be about classes, namespaces, events, type safety and the almighty compiler. I dont want to see any HTML or any "pages" of any kind. The page model in web development is a remnant from the old days when the web consisted of documents which contained information. Organizing programs by pages just doest make sense anymore. Making a page a class doesn't help either - that's just a quick workaround. I've been kicking around the idea of writing my own control library for ASP.Net, and I've got some rough prototypes coded already, but I dont wan
-
how do I send email from Asp.net?I need to send an email from an asp.net page. The problem is Microsoft have locked down permissions for SMTP and the process controlling IIS doesn't have permission to send mail. The error code I get is 0x80040220. If I run exactly the same code from a Win32 app, the email gets sent without any problems. Does anyone know a way around this? Ideally the solution is something I can set in my code - it will make it easier for the end users of my asp app. many thanks
-
how do get permission to send an email from ASP.net?hey - I'm hoping someone on the forum can help me with this. It's a fairly mundane problem, but I can't seem to get around it. I cannot send an email from an ASP.net application. I get the 0x80040220 error - basically, I don't have permission to send email. Exactly the same code run from a Win32 app works perfectly. A check at MSDN comes up with a slew of solutions, ranging from the vague ("run your web app with correct permissions") to the amazing (download Exchange Server SP3, weighing in at 160+ Megs). I'm developing a small open source app that needs to send email from an ASP page - I'm looking for a clean and elegant solution to this problem - something I can set in my code without having to ask ppl who use my app to monkey around with their IIS permissions or download a 160 meg "patch". Any ideas? I'd really appreciate them. After spending weeks banging together my application, it's pretty annoying that it fails on something as trivial as not being able to send out a simple email.
-
how difficult does getting an instance by handle have to be?The exact use is I need to send a string message from one instance to another (the string message being the file name the one instance wants the other one to open). This has to be done from the static Main() method. The simplified code could be : // this is the main "starting" class of my app class MainForm() { public static void Main(string[] args) { // gets instance of this app already running MainForm otherAppStance = objCleverWidget.GetOtherInstance(); // sends message to other instance and quits if (otherAppStance != null) { otherAppStance.TransferMessage(args[0]); return; } } public static void TransferMessage(string strMessage) { MessageBox.Show( "The other instance says" + strMessage ); } } So what I really need to know is how to make objCleverWidget.GetOtherInstance() This will return the instance of the main Window Form from the other app instance, and all my problems will be solved. That's the ideal solution. I haven't had any luck coding it, so I came up with a small but crude workaround - use P/Invoke's SendMessage. SendMessage is limited though - you can't send strings with it, just a message id in the form of an uint, and two pointers which I can't figure out properly. So I converted my string message into chars, converted each char to its uint equivalent, and sent those uints as message id's from one instance to another (obviously using some start- and end-message flags). It works and uses very little code, but I'm not too sure how well it will stand up to scrutiny. Oh, and it kinda destroys the recipient app's main form - you have to redraw after receiving messages. Doesn't sound too healthy ... I've seen two other solutions online, one in VB (on codeproject infact) which I dont understand too well (VB + interop = brainmelt), and the other using Remoting, which raises questions of its own (assumes user pc will have network support). I was surprised by how much code was used in both solutions - my workaround was pretty light. Anyway, associating an application with a file type is a pretty standard requirement, so I am a little puzzled by the lack of built-in functionality in the .Net framework for this kind of thing. If you can point out a practical solution that doesn't use networking, please let me know. I have reason to believe P/Invoke's SendMessage will do the trick, but I need to find out how to use it's two pointer parameters. Th
-
How do I do double-click file opening with my C# app?Sorry, I guess I wasn't being clear enough. Yeah, that article was doing what I wanted. The solution just seemed overly complex, and it was in VB (I'm using C#). Plus I'm writing an open source application, so I have to be careful what code I compile into my app. At the time I didn't realise it would be so much work to have one instance of an application contact another - I figured it was just a case of getting the instance via its handle, which I now understand is not enough. Thanks for your help ... guess I'll be taking a closer look at that VB code after all.
-
How do I do double-click file opening with my C# app?ok, but how do I get the previous instance then? These examples are all for preventing multiple instances. I think the 2nd one has some useful code that allows me to get the process object for the previous instance, but I can't seen to get the actual instance of the application (a winform object) from that process object, so I'm still kinda stuck. Any ideas?
-
how difficult does getting an instance by handle have to be?I want one instance of an application (let's call it instance2) to get another instance (instance1) of the same application. Instance2 already has the handle of instance1 - I've checked, and the handle's match. But in instance2, if I do : IntPtr hdlInstance1 = [whatever I do to get the correct handle]; Control myInstance1 = Control.FromChildHandle( hdlInstance1 ); then myInstance1 is always null. I can use Control.GetHandle(hdlInstance1) as well - that doesn't work either. Is there some special way I'm supposed to get instances by handles? I can't find any useful info online. And has anyone noticed how often code sites have the easiest, most trivial examples of a subject, like in this case, how to stop there being more than one instance of an application, but none of the sites will even dare doing something a bit more advanced like actually doing something with the second instance instead of just blocking it? It's almost like code sites just rip eachother off - one site puts up a simple example, then everyone else just copies it. Sigh .... rantmode off. Thanks in advance.
-
How do I do double-click file opening with my C# app?I've written an app in C# - let's call it Foo. Foo creates *.Bar files. I want to enable double click support in Windows for *.Bar files, so Windows automatically opens the file in a running instance of Foo. I already know how to get Windows to start Foo up when I double click on a .Bar file - simply associate the file type using Windows Explorer (for example), and use the args[] string array argument in the Main(args[]) method of Foo. This acts as a list of files to open when Foo starts up. But what happens when Foo is _already_ running? What pathway does Windows use to send an open-file instruction to Foo? Does it go through the Main() method? I've written Foo so only one instance of it will run at a time, so I need to be able to get Windows to tell the existing instance of Foo to open a file. Any ideas how this is done? Thanks