C# - Better And Safer Way Than Using: #define DEBUG
Feb 11, 2011
In one of my asp.Net pages I want to set some properties of a user control so that it behaves differently to make things easier and faster while I debug and test my page.I want to compile the code block where I set my properties only if I am running the VS in DEBUG. I know I can use conditional compiling
I want to debug EditPanel.debug.js file of HTML Editor, but it never shows in VS 08 and Im sure it executes to that line.What I did to enable debuggingUnchecked both 2 checkboxes for disabling the debugging
Set ScriptMode="Debug"
Change following line
[ClientScriptResource("AjaxControlToolkit.HTMLEditor.EditPanel", "AjaxControlToolkit.HTMLEditor.EditPanel.js")] to [ClientScriptResource("AjaxControlToolkit.HTMLEditor.EditPanel", "AjaxControlToolkit.HTMLEditor.EditPanel.debug.js")]
Debug-Start Debugging/Debug-StartWithoutDebugging OR Project ASP.Net Configuration launches Dreamweaver. It started lastnight, I had both Deamweaver and VWD 2008 express open at the same time - (I was looking at JQuery in the Microsoft and Dreamweaver enviroments simultaniously). After the first tie this happened, I closed down Dreamweaver (CS3) and it opened when I tried to run my VWD project. I reinstalled VWD 2008 express, IIS and disabled Dreamweaver (renamed the exe). Dreamweaver still came up.
How to set the selected value for this Dropdownlist box?
<%=p.MessageType%>.. this is the value I am getting from database so that In my Grid what ever the Value coming form database it will show in the Dropdownlistbox on the Grid now its showing me as Default value P even Database value B
I like to handle and compare a lot of date times in my repeater even I have to work more than one time with the same.
It's a bit ugly, to cast everywhere the Eval("MyDate") like ((DateTime)Eval("MyDate")) to substract 2 datetimes or to compare it, even if you have to do this more than in one operation.
I thought of saving all the evals in a var at start of the repeater?
where should commonly used utility functions (to be used in multiple .aspx files) be coded? I currently have these common funcs in an .ascx user control that's referenced in each .aspx file.
I want client access a data center but without use database , so I want my web app can retain a global or Application session variable, that contains the data, every client can access the same data... I am try to declare in golabl, but seem it only can store String but others ..
to define a variable/property of more than one type. Let's say i want a property TextWebControl that is a WebControl and also implements Web.UI.ITextControl(f.e. like a TextBox or Label). But i don't want to enforce that it is a TextBox or Label, but only one that inherits from WebControl and also implements ITextControl so that it also would work with controls added in future releases of .Net-Framework.
.Net-Framework 4.0
Edit: I have retagged the question and added VB.Net because it's my default language. Normally it's no problem for me to understand C# also, but i must admit that it's difficult to translate generic stuff to VB.Net without experiences and it's also better documentated in C# than in VB. So i would appreciate(and aceept) a working example of a VB.net generic type of ITextControl/WebControl.
From Marc's answer i understand that i need a generic class. But how do i instantiate it in SomeClass? This won't compile:
Class SomeClass Public Property info As InfoControl(Of WebControl, ITextControl) End Class
I'm using MySql in my asp.net project. But I don't want to type every "using MySql.Data.MySqlClient;" statement in every aspx.cs/aspx.vb file. How can I define this lines in web.config file?
I've defined some namespaces like below but this only works for aspx pages:
Define Generic in one line / I know that List<string>, Stack<string>, Queue<string>, Dictionary<string,string> & linkedList<string> alls are generic but i want to know its one Line
I'm reading about URL routing at How to: Define Routes for Web Forms Applications and there's something in the example I don't understand. If you look at the example provided below,
i want to add [Authorize] to specific roles; some for registered users and other for admins , but when i have created my mvc2 web application , i can only register new users but without roles and when i checked the aspnet_role table i found it empty, so how i can define admin roles for some of the registered users and the user role for the rename users
I want to define a DataList in the code behind but i don't know how to do it.
I just just know how to do it in the ASP.NET:
Data Source DataList
<asp:AccessDataSource ID="adsExample" runat="server" DataFile="~/MyDatabase.mdb" SelectCommand="SELECT Best4.[Year], Countries.Flag, Countries.ENAME AS Champion FROM (Best4 INNER JOIN Champions ON Best4.CHID=Champions.CHID) INNER JOIN Countries ON Champions.CountryID=Countries.CountryID ORDER BY Best4.[Year];"> </asp:AccessDataSource> DataList <asp:DataList ID="DataList1" runat="server" DataSourceID="adsExample">..........
When i am running my Visual Web Developper, the result is a list of x numbers of three values: