Posts

Donate

The Controls collection cannot be modified because the control contains code blocks(i.e.<% …%>) (ASP.NET HTML Editor Extender)

After adding an HTML Editor extender to my asp.net page, an error shows when rendering the page to the browser as stated which is the title of this post. I found the solution in asp.net forums which is to wrap aspx markup codes enclosed with <% %> using placeholder control. The code below is in my ASP.NET Master Page: <head runat= "server" > <title></title> <link href= "~/Styles/Site.css" rel= "stylesheet" type= "text/css" /> <asp:PlaceHolder Runat= "server" > <script src= '<%=Page.ResolveUrl("~/Scripts/jquery-1.4.1.min.js") %>' language= "javascript" type= "text/javascript" ></script> </asp:PlaceHolder> <asp:ContentPlaceHolder ID= "HeadContent" runat= "server" > </asp:ContentPlaceHolder> </head> Reference: Handling Ajax Extenders Error :)

ASP.NET jQuery $find() Not Working In Onclick() Event Of Radio Button

In an application where i want trigger the onclick event of radio button that has a $find() method, which will retrieve the radio button's value, the code below doesn't work. <input type= "radio" id= "rb1" name= "format" value= "format2" runat= "server" onclick= "$find('<%=dpe1.ClientID %>').populate(this.value);" /> d.m.y <input type= "radio" id= "rb2" name= "format" value= "format3" runat= "server" onclick= "$find('<%=dpe1.ClientID %>').populate(this.value);" /> y/m/d where dpe1 is a DynamicPopulateExtender Ajax Extender.The solution I made was to remove the populate logic and transfer it to a javascript function. Here's the revised code: //javascript code function rbFunction() { //$find('<%=dpe1.ClientID %>').populate($("input:radio:c

ASP.NET Gridview Not Getting New Values In RowUpdating() Event

Assuming in your row updating event, you do some editing in your textbox and then click update button. The event in turn saves your modified records to the database. However, when you tried rebinding the datasource of Gridview it seems that you didn't get the newly updated values. The simple trick would be to set the Gridview property EnableViewState to false .

Get Current ID In Task Object (C#)

Doing some research on Task (TPL) i wonder if there's a way in retrieving the id of the current task executing. In thread, we can do it like this: Thread.CurrentThread.Name; The equivalent code in task is shown below: int currentTask = Task.CurrentId; Greg

Pivot Or Crosstab SQL Query Example

Image
Based from Visual Basic Forums, I learned a tip on using Crosstab/Pivot queries. This is presented with SQL Server Execution Plan. It's better to use the concept of the second one compared with the first one. SELECT SUM ( CASE WHEN DATEDIFF( DAY , upload_package_received_date, GETDATE()) = 0 THEN 1 ELSE 0 END ) AS Today, SUM ( CASE WHEN DATEDIFF( DAY , upload_package_received_date, GETDATE()) <= 7 THEN 1 ELSE 0 END ) AS Last_Week, SUM ( CASE WHEN DATEDIFF( DAY , upload_package_received_date, GETDATE()) <= 30 THEN 1 ELSE 0 END ) AS [30 Days Ago] FROM temp_uploadpackage Second Example SELECT ( SELECT COUNT (1) FROM temp_uploadpackage WHERE DATEDIFF( DAY , upload_package_received_date, GETDATE()) = 0) AS Today, ( SELECT COUNT (1) FROM temp_uploadpackage WHERE DATEDIFF( DAY , upload_package_received_date, GETDATE()) <= 7) AS Last_Week, ( SELECT COUNT (1) FROM temp_uploadpackage WHERE DATEDIFF

How To Reference System.Web.Mvc In Class Library (ASP.NET MVC)

If your going to add reference to System.Web.Mvc in your class library, simply locate the assembly in Microsoft ASP.NET folder in program files. Using search in windows explorer in my workstation, the assemblies are located here: C:\Program Files\Microsoft ASP.NET\ASP.NET MVC (version_number)\Assemblies Greg

DataGridview Current Row Returns Null In SelectionChanged Event

When retrieving selected row cell values in the DataGridview, you might encounter object not set to reference of an instance. It's because the current row has not been initialized. Check first the cell value of the current row if it has cell contents. private void dgvAccounts_SelectionChanged( object sender, EventArgs e) { string countryName = string .Empty; if (dgvAccounts.SelectedRows.Count > 0) { if (dgvAccounts.CurrentRow.Cells[1].Value != null ) { countryName = dgvAccounts.CurrentRow.Cells[1].Value.ToString(); } } } This will ensure that databinding has finished. Cheers!

A field or property with the name 'ClassName.Property' was not found on the selected data source In ASP.NET Gridview

As i was running an asp.net application in my local machine, I encountered an exception which is the title of this post. This asp.net app runs perfectly from the other workstation. I tried searching solutions in google but found out that most of the recommendations were to redo the model or the business tier. One option I tried was to replace the BoundField of the gridview with TemplateField with label as the bound control using Eval("expression"). Glad that worked. It could be an IIS issue as stated in other forums. Here's the gridview markup changes: (Windows 7 64 Bit using BoundField) <asp:BoundField DataField= "Product.Name" HeaderText= "Name" > <ItemStyle Width= "350px" /> </asp:BoundField> (Windows 7 32 Bit using TemplateField) <asp:TemplateField HeaderText= "Product Name" > <ItemStyle Width= "350px" /> <ItemTemplate> <asp:Label ID= &quo

Using AutoMapper In Asp.Net Web Forms Database Application

Image
Hello, Based from Scott Millet's Asp.Net Design Patterns , I was curious on the AutoMapper Framework that maps Domain Entities to View Models. So I tried to give it a spin by incorporating the tool in an ASP.NET WebForms application. Here's the code snippets breakdown: Order class: /// <summary> /// One order may contain one or many order details. /// </summary> public class Order { public int OrderId { get ; set ; } public DateTime OrderDate { get ; set ; } public DateTime RequiredDate { get ; set ; } public string ShipName { get ; set ; } public string ShipAddress { get ; set ; } public IList<OrderDetails> OrderDetail { get ; set ; } } Order View class: public class OrderView { public int OrderId { get ; set ; } public DateTime OrderDate { get ; set ; } public DateTime RequiredDate { get ; set ; } public string ShipName { get ; set ;

WPF Datagrid Paging In VB.NET Using CollectionView Class

Image
Based from the solution posted by timmyl here: How can I paginate a WPF DataGrid? . I managed to fix some bugs and added some functionalites such as MoveToFirstPage and MoveToLastPage. Paging Class 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 Option Infer On Imports System.Collections Imports System.Collections.Generic Imports System.ComponentModel Imports System.Windows.Data Public Class PageCollectionView Inherits CollectionView Private ReadOnly _innerList As IList Private ReadOnly _itemsPerPage As Integer Private _currentPage As

Donate