
utilitaire
Avatar/Signature-
Posts
77 -
Joined
-
Last visited
Content Type
Profiles
Forums
Blogs
Events
Articles
Resources
Downloads
Gallery
Everything posted by utilitaire
-
Ok I figured it out! Thank you very much. I find it much easier to find bugs in my website project when I use my other DLL in release mode. Thank you very much!
-
Ok can you elaborate? I think I understand what you mean but I dont really know how to do that in Visual studio. So you're telling me this is done without adding any kind of code in my DLL. All I have to do is to use the DLL in "release mode" instead of "debug mode". I'll try to find out by myself but If you could tell me how to do it, It'll be helpfull! Thank you.
-
When I use objects like System.Web.UI.Page, I can generate exceptions that will occur inside some properties or methods. For instance, If I try to access the "Session" property in the Page Constructor, it will generate an error. However, the code that threw the exception will always be hidden from me. I mean I will never see the "throw new Exception" line inside the "Session" property of the Page object in my browser. The browser will show me my own line, in witch I called the "Session" property. Example: public class MyPage: Page { public MyPage() { Session["test"] = "test"; } } This code will generate an exception. However, even if the exception is thrown inside the Session property, my browser will only show me my own code. I wonder how to do that with my own code. This could be very usefull.
-
I have a file Templates.config that contains templates for my controls: <Template> <add Id="myTemplateDataGrid" Type="DataGridPreset" HeaderStyle-BackColor="#ffffff" BorderWidth="0" BackColor="#EEFBF0" GridLines="None" CellPadding="3" CellSpacing="0" Font-Name="Verdana" Font-Size="14pt" AlternatingItemStyle-BackColor="#DEF8E2" AutoGenerateColumns="false" /> </Template> I first put all these attributes in a list. This is Easy. After that, I want to merge these attributes to my current server control. Its goes like this: PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(myDataGrid); properties["borderwith"].SetValue(myDataGrid, 2); I can do that. The probleme comes with composed style. For instance: "AlternatingItemStyle-BackColor". I can't use this propertyName since its not ONE property. At this point, I find this buntch of code very complicated and I'm sure there a parser somewhere in ASP.NET that can do that for me. Have you ever heard of something that can do that? After all, asp.net has to parse all theses attributes when it loads the server control. Thank you
-
1) Application["myarray"] = new Int[2]{1, 2}; Int[] myarray = (Int[])Application["myarray"]; int data = myarray[0]; I think it works. 2) you mean something like mymsn? I'm not sure its a .net issue. Its done using javascript if I'm not wrong, and has nothing to do with asp.net. Maybe ASP.net make it easier to create such script...
-
Up to now, all the classes I've created in my current project have been in a specific namespace, with the same directory logic tree. It is really easy to find a class when a project is structured. If I'm looking for the Tools.IO.email class, I know I can find it in the Tools.IO directory on my computer. Fine. But Is there any good reason to organise the namespaces so that they dont fit the directory tree on your computer? For example: I have a namespace called «mycontrols». In this namespaces, I have, lets say, 20 different controls. When I want to use these controls in a webform, I just put the register tag with a single namespace: <%@ Register TagPrefix="C" Assembly="Tools" Namespace="Tools.mycontrols" %> After that, all my controls can be used with the «C» prefixe. However, suppose I have many types of controls(validation, panel, etc.).I want all my controls to have the «C» prefixe in my code. I'd have to put them in the same namespace right? But it would be better to have all the validation controls in the same directory, just like I would like to have all the input controls in the same directory. Therefor, I'd have to make the namespace logic not fit the directory logic. Anyway, I just want to know if this is a good practice sometimes to organise the namespaces tree so that they dont fit the directory tree. Thanks!
-
I dont think its about the method itself. Its probably the Session object you're trying to have access within your method. I've seen this error many time in the OnInit context. Session is one of the objects you cannot have access in this context. You have to wait to the OnLoad event. But first make you method public or it will never work. Make it public, an then check if your method is called within the OnInit context. If so, you'll have to take away the Session object.
-
That's what I always do. I think this is quite performant, since: 1) as you said, Double.TryParse probably do a try/catch 2) the IsNumber() will probably be used most of the time with a number. Maybe 10% will generate a catch(). Depends how you use it, but If you actually expect a number, how many time the user will send a string that is non compatible? The user will send a number most of the time.
-
Do I have to install VSS 6.0 after VS2005? I have tried this yet. I dont remember if that's the way I proceed for VS2003...
-
I need to say I uninstall vs2005 after having this VSS/teamp foundation problem. I'm waiting for a solution cause I cannot start the translation of my website. :confused:
-
I've been working for 2 months on visual studio 2003 with source safe 6.0 with my partner in a new web application. After we managed to synchronize our work with source safe, I decide to upgrade to visual studio 2005. The main reason was the new tool that allow us to auto-generate resource files. This tool is supposed to loop through all controls and insert texts into the resource files it creates. The problem I had with vs2005 is VSS. Visual source safe desn't seem to work no more in vs2005, am I right? The new source control is «team fondation». I just can't manage to understand how team fondation server is supposed to work. Actually, I understand how the client works. But how the hell can I install the server??? I found a guide on MSDN but It wasn't clear at all. Is it that complicated to simply install the team fondation server with vs2005??? Thank you for you help!
-
Its not really possible. Web application are not made for asynchronous operations. It is possible to send a request to a database server, but it's not supposed to be used in a web application. The reason is that a web application is suppose to execute a page quickly, render the result to the client, and then free the memory. Suppose you have 200 request at the same time, you absolutely cannot hold the execution for seconds(minuts) since it would cause a memory leak. If you wonder if it is theoriclally possible, the answer is yes. Set the script time out to illimited time, and store all the SQL code inside a stored procedure. Even if the stored procedure takes 5 minutes to execute, IIS will still be waiting for the result in a synchronous operation. But if I was you teacher, I would tell you this is a REALLY REALLY REALLY bad practice and that you should forget about it. :)
-
thank you so much! I didn't event know this method was fired each time a page is requested!! Simple and perfect! Thank you again! :)
-
Ok its interesting but I dont really understand what this call is actually used. :rolleyes: Maybe you have an article somewhere on the web that describes this kind of class, with the a complete example. Thank you again!
-
Here's the problem: I have a webform with many usercontrols. Those controls override the OnInit method, and the OnLoad method. The code runs fine, but I have some problem synchronizing all this. I have a certain routine I would like to execute each time a page is called by a client. This routine has to be done before ANY usercontrol is Init or Loaded. The question is: how do I do that? Where do I have to put the code in order to be sure It will be called before ANY other code? I tried in the «Init()» method of the main Page. It doesn't work since this «init» method is called after all controls in the page are called. Here's the scenario: 1) A client make a request. 2) The Page checks if the language in the URL (http://www.mysite.com/en/) is valid. My valid languages are "en" and "fr". If any other languages are specified, I redirect the client to a valid default language. 3) After the redirection, the new page (the good one) is executed, with all the controls in it. The «init» method is called for all controls, etc. I want to make sure the step 2 is executed before step 3. I'm sure you faced this kind of problem. Any suggestion? PS: Dont suggest me to do that in the global.asa, since the session_onstart method is only called once, and not each time the client make a new request for a page.
-
Thank you all guys! I already use many stored procedure (hundreds). What I want to know, is even if you use stored procedure in your code, do you actually put all those queries(stored procedure calls) into a separate class, or do you simply put those procedure calls directly in you logic code? Stored procedure encapsulated in a class: public class MyMedia{ public DataSet GetUsers(){ return mySqlObject.RunQuery("exec ps_getUsers"); } } Stored procedure calls directly in the logic: public void Page_Load(){ string user = Request.QueryString("userid"); DataSet da = mySqlObject.RunQuery("exec ps_getUsers " + user); Response.Write(user); } Is there a benefit in putting the queries (procedure calls and so on) in a separate class? Until know, I've never done that. But before starting my new project (.net), I want to be sure I using the best methods. Thank you again!
-
Ok But I think I saw an article somewhere about people who actually create a classe (databaseAccessLayer) that contains all access queries to external data. Here's an example: public class myMedia{ public datatable getUserInfo(){} public datatable getUserLogged(){} public datatable getStats(){} public datatable getPassword(){} public datatable getVisitors(){} public datatable getIPVisitor(){} public void SetUserPassword(){} public void SetUserCountry(){} public void SetUserName(){} } This class can be used after that in the engine: myMedia m = new myMedia(); m.SetUserName(userid); m.SetUserCountry("Canada"); Is this a correct way to encapsulate the data access?
-
Here's an example of method in a database class: public DataTable GetUserInfo(string userid){ return sqlobject.Read("select * from user where id =" + userid); } This method encapsulate all info about the user. In this way, I guess I can easily reuse this method in many pages, since it return all the data from the table. However, each time I call this method, It will read all the column in the table, even if I only want a few of them. Here's a second method: public DataTable GetUserPassword(string userid){ return sqlobject.Read("select password from user where id =" + userid); } This method only returns the password of the user. This time, the query is more performant since it wont return unecessary data. However, I wont be able to reuse this method very often. It will be usefull only when I need a password. Therefor, is it really usefull??? If I only use this method one time in the whole web site, why would I like to encapsulate this query? If I have to create a different method for each every possible combinaison of INNER JOIN and LEFT JOIN and UNION and WHERE in my database, I will have to create 300 methods in this class. Do you have a example of this kind of class? I'd be interested to see how you do that. thank you!
-
The problem is that I have a website with more than 300 asp pages and 300 or 400 SQL queries, and I'm not really reusing my queries. Maybe 30 SQL queries are reused in the entire site. The thing is, I have to keep all queries very optimized. I cannot accept to do things like «select * from ..." or stuff like that. Therefor, queries tend to be very different from page to page. I assume that people who work with database classes that encapsulate their queries dont care much about requesting unecessary data to the SQL server. Is this really a good practice? If I create a class that encapsulate my queries, will it be really helpfull since I cannot really reuse theses methods in other pages??? One method, one page. 300 pages, 300 methods. :confused:
-
How many of you split their website into 3 dll: 1) Visual part (aspx) 2) Engine (code-behind) 3) Database access I already code all my webforms in code-behind. However, I haven't split the code-behind so that all database queries would be in a single classe (or group of classes). I've seen this approach somewhere on the web, but I'm not so sure I want to use it. Here's an example: Instead of doing this in a typical code-behind page: sqlcommand = "select * from user"; ... I could do something like this: MyProjectDataBase mpdb = new MyProjectDataBase(); ArrayList a = mpdb.GetUsers(); What do you think of this approach? In this way, all queries are encapsulated in a single DLL. All IO access are separated from the engine part. The problem I see is that I have to create another method EVERY SINGLE TIME I want to create a query.
-
I never faced this kind of problem. The only thing I can think of is the "session state enable". Maybe it is set to «false» in the web.config?
-
Ok very interesting. It's a good idea to stock the UniqueID/ID as the index in the resource file. However, if I loop through all the controls: 1) I'd have to find a way to assign the text to the control in a uniform way. Since all controls dont have the same property name that describe the «text», I'd have to do a lot of «if». Example: if(control is textbox) control .text = myString; if(control is label) control .value = myString; Maybe an Interface could solve this problem. 2) If I loop through all controls recursivly on the production server, I might become less performant. Actually, I dont know how much those things can slow down a server. I'm new to ASP.NET, but in classic ASP, I used to face a lot of performance issues. 3) "you CAN create Multi-Lingual websites with CSS". Can you explain a little more? I really dont understand what css has to do with it. :eek: Thank you for you help!
-
I have a question for you guys about a regular expression i want to build. I have a string that i want to test. I have my pattern that should be 1 to X times in my string. Thats works. But also, my customer can pass an empty value for this string. If my customer pass nothing, i want my regular expression to succeed also cause i accept empty value for certain textbox. I cant figure out how to manage an empty value in my string. Hope someone can give me a hint on that. Thanks in advance.
-
Ok I've never heard of google localization. Resource files are good. I'll make more research on what you said. Thank you. :)
-
Using two form runat-server in the same webform?
utilitaire replied to utilitaire's topic in ASP.NET
And by the way, for the bandwich thing: my web site has more than 4 millions hit per day. So I cannot really underestimate the benefit of the optimizating the data sent back and from the server. ;)