asp.net-4.0

Which is the recommended way to fill all controls on a Web Form when user selects a record?

馋奶兔 提交于 2019-12-19 16:48:35
问题 I have a GridView control which shows a list of all employees. When user selects any employee from this list, the record is shown on a Web Form with all input controls pre-filled with the values. I want to know any good approach to do this. Should I bind all input controls to any SqlDataSource or should I re-populate all input controls by picking values from the DataSet. 回答1: First you add the select button on your GridView as: <asp:ButtonField Text="Select" CommandName="ViewMe" ButtonType=

.Net 4.0 is encoding single quote when using Attributes.Add

懵懂的女人 提交于 2019-12-19 16:09:35
问题 .Net 4.0 is encoding single quotes when I am using Attributes.Add to add client side events to my asp.net objects. In the previous versions this didn't happen. for example : <asp:Image runat="server" ID="imgTest" ImageUrl="~/DateControl/cal.gif" /> imgTest.Attributes.Add("onmouseover", "alert('Hello')"); When I view the client side output, I am getting <img id="ctl00_MainContent_calFromTimeStamp1_imgTest" onmouseover="alert('Hello')" src="../DateControl/cal.gif" style="border-width:0px;" /> I

Binding GridView to IQueryable<T>

安稳与你 提交于 2019-12-19 03:23:10
问题 This question is purely academic, because I'd never dream of doing this in real code. Using LINQ to SQL, I want to bind an IQueryable<T> to a GridView. I tried doing this with the following code, but I get the exception: Cannot access a disposed object. Object name: 'DataContext accessed after Dispose.'. Here is my code that gets an IQueryable<tabGenre> using LINQ to SQL: public static IQueryable<lu_Genre> GetGenres2() { using (BooksContextDataContext ctx = new BooksContextDataContext()) {

The directory '/website/App_Code/' is not allowed because the application is precompiled

孤街浪徒 提交于 2019-12-18 18:48:35
问题 How can I resolve the below issue that I get when I am running my precompiled web app? Server Error in '/CRM' Application. The directory '/CRM/App_Code/' is not allowed because the application is precompiled. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Web.HttpException: The directory '/CRM/App_Code/' is not allowed

Asp.net checkbox and html data attribute

蓝咒 提交于 2019-12-18 14:13:14
问题 In asp.net, if you use a custom attribute, usually it is rendered as-is. Considering this markup ( note: attributes such as id , name and for were removed in all examples as their generated id/names are verbose): <asp:TextBox runat="server" data-foo="bar" /> Is rendered in asp.net as: <input type="text" data-foo="bar" /> That is, asp.net keeps data-foo untouched. Check box are usually rendered like this: <asp:CheckBox runat="server" Text="Normal" /> Renders as: <input type="checkbox" />

ASP.NET MVC 3: How to get User's Role in a Controller Method?

泄露秘密 提交于 2019-12-18 12:24:45
问题 I want to be able to Get a list of roles of the current authenticated user. Filter the data provided to that user based on their role. I see ways to check if the user is in a particular role, but I don't care what role they participate. The database will know what roles are allowed to see what data. I need to submit a collection of these roles to the data service to filter the data based on those roles. So first step is how do I get all roles associated with the current user in a controller

How to get rid of ugly asp:Menu flickering?

女生的网名这么多〃 提交于 2019-12-18 10:54:37
问题 I'm using the asp:Menu control on an ASP.NET 4.0 Webforms page with table-free rendering mode: <asp:Menu ID="MenuBase" runat="server" DataSourceID="SiteMapDataSourceMenu" Orientation="Horizontal" CssClass="contentmenu" RenderingMode="List" IncludeStyleBlock="false"> </asp:Menu> The menu has a horizontal main row with 5 or 6 menu items and some of them open vertical popup menus when the user hovers over them. Often when any postback occurs and the page gets rendered again the menu "flickers"

InvalidProgramException: Common Language Runtime detected an invalid program

房东的猫 提交于 2019-12-18 08:47:50
问题 All, I'm running into trouble deploying an ASP.NET 4.0 web page. The error is System.InvalidProgramException: Common Language Runtime detected an invalid program The error occurs on IIS7 on a 64 bit Windows Server box. The same page works on IIS7 on my development box (32bit Windows 7) and in the Visual Studio Development Environment. I'm not aware of any differences in the IIS7 configuration. I've used PEVerify to validate the dll's in the application's bin directory. I can reproduce the

Populate Dataset With Table Names From Stored Procedure

被刻印的时光 ゝ 提交于 2019-12-17 14:51:15
问题 I have a stored procedure that returns multiple tables. It populates my dataset correctly but it names my tables [ Table , Table1 , Table2 ,...]. Is there something I can add in the database layer (to my stored procedure) that will name the tables properly? 回答1: Your SP is not actually returning multiple tables, its returning a selection of columns and rows from your tables, therefore there is no 'table name', and hence why they are named table1, table2 etc. If its important, you could return

asp.net 4.0 web forms routing - default/wildcard route

二次信任 提交于 2019-12-17 11:01:51
问题 I there a simple way when using ASP.NET 4.0 routing with Web Forms to produce a route that will act as some kind of wildcard? It seems to me that within WebForms, you have to specify a route for every page - I am looking for some kind of generic route that can be used where nothing specific is required, perhaps mapping directly from path to path so... http://somedomain.com/folder1/folder2/page would possibly map to folder1/folder2/page.aspx Any suggestions? Thanks 回答1: You can match all