Owner: Articles for ASP.NET, C#, VB.NET, MS SQL, Framework 2.0,3.0,3.5 URL:http://aspnetsource.com/blog/Default.aspx Join Date: Fri, 11 Jul 2008 07:36:42 -0500 Rating:0 Site Description: Articles for ASP.NET, C#, VB.NET, MS SQL, Framework 2.0,3.0,3.5 Site statistics:Click here
Hide form after user download file 0000-00-00 00:00:00
Before user download a file from our asp.net app, we may want him to fill some form with information(ex. names, e-mail, etc.) and when press downlaod button the form should be hidden:
in aspx page:
<asp:Panel ID="_getInfoPanel" runat="server">
YourName: <asp:TextBox ID="_yourNameTB" runat="server" />
. . .
Menu in Master Page. How to set selected item from Page? 0000-00-00 00:00:00 We always use master pages in our asp.net work. Very often in mater page we put site navigation - menu. The menu is same for every page, but to make more clear which page is currently opened, we can make some menu item selected on one page and other menu item selected on other page.
First example is when we have menu by HyperLinks, and for unselected menu we have css class unselected and for selec Read more:Master
Overview of New in Framework 3.5 0000-00-00 00:00:00 In this Article, we'll make overview of new in .NET Framework 3.5:
LINQ (Language-Integrated Query) - makes more closer word of objects and word of datas. In LINQ queries are on code lever, you'll write them as code expression. LINQ expreesion can be written in C# or Visual Basic with SQL Server, XML docs, ADO.NET Datasets and any collection that supports IEnumerable(also for Generic IEnumer Read more:Overview
New in Framework 3.5 - Generic Class HashSet 0000-00-00 00:00:00 In Framework 3.5 there's new Generic
Class - HashSet<T>.
The HashSet<T> class provides a set of operations with high performances. All elements in HashSet<T> are different from each other, also they're no sorted is some order after adding.
Follows an example which demstrates functionality of the HashSet:
HashSet<string> hashSet = new HashSet<string>();
hashSet.Add(&q
Present XmlDataSource data with Repeater 0000-00-00 00:00:00 It's very easy to load data from xml file and to present it in the way you want. We prefer to use that method for small data which rarely is being changed.
In the example below, we have xml file which contains items(url and info) and we want to represent that data on page: links(<a>) with info for them, separated in paragraphs(<p>):
in App_Data/db.xml we have:
<?xml version="1. Read more:Present
How to Validate ImageButton control through W3C 0000-00-00 00:00:00
in aspx page(Frameworks: 2.0, 3.0, 3.5):
<asp:ImageButton ID="ImageButton1" ImageUrl="~/img.gif" runat="server" onclick="ImageButton1_Click" />
that'll be rendered to HTML page in this:
<input type="image" name="ImageButton1" id="ImageButton1" src="img.gif" style="border-width:0px;" />
Un Read more:Validate
Using Find Method in Generic Controls With VB.NET - T List<T>.Find(<T> item) 0000-00-00 00:00:00 Using Find Method in Generic
Controls With VB.NET - T List<T>.Find(<T> item)
When using VB.NET, and try to search for element in class List, there’s no elegant way for doing that(as with C# ex. List.Find(delegate (T t) { return item == t; } ); )
Reason for that is VB.NET doesn't support anonymous delegates. You could do what the C# compiler does, create a little
Using Find Method in Generic Controls With C# - T List<T>.Find(<T> item) 0000-00-00 00:00:00 Using Find Method in Generic
Controls With C# - T List<T>.Find(<T> item)
Well, it’s little strange to us that in class System.Collections.Generic.List<T> there’s no overloads for method Find with parameter <T> item (only public T Find(Predicate<T> match)), so if we have:
List<T> list and want to search for T item(local variable) in
Script injections using ASP.NET 0000-00-00 00:00:00 1. Introduction - What is Script injection ?
Script injection attacks occur when a hacker fill one or more input fields with malicious programming code and then submits the form. If malicious code is not handled and saved to database, it can occur from boring alerts messages to unwanted database deleting or access data from database.
The basic technique for a scr
Easiest way for Row Numbering in GridView 0000-00-00 00:00:00 Sometimes it's good idea to use row numbering in GridView, we use it in :
You can do this very easy:
<asp:GridView ... >
<Columns>
<asp:TemplateField HeaderText="#">
<ItemTemplate>
<%# Container.DataItemIndex + 1 %>
</ItemTemplate>
...
</Column
Framework 3.5: Disadvantage of lamda expressions 0000-00-00 00:00:00 something very cool thing in asp.net developing with Visual Studio is the debugger: in QuickWatch you can write everyting: variables, call functions to see result by them, ... everything, ... Well, almost everything: in new debugger: you cannot see result of lambda expressions:
it's not big deal but until this moment I've used to 'quickwatching' everything, but now the debugging will be a little
LINQ - display filed from parent table in LinqDataSource and GridView 0000-00-00 00:00:00 Using LINQ we'll faced with that scenarion:
in Db we've two table:
Parents(ID, parentText) and Childs(ID, ParentID, childText).
in aspx page we've GridView and LinqDataSource with TableName="Childs" and we want in GridView to display parentText from Parents,
in past when we've used SqlDataSource in SelectCommand we've added JOIN Parents ON Childs.ParentID = Parents.ID, but with linq it Read more:filed
LinqDataSource and Guid passed as QueryStringParameter 0000-00-00 00:00:00 Very often in our practicе we pass Guid as QueryString Parameter (ex. Default.aspx?someId=e2716920-0c21-4a46-8d19-f05b12f22c5b), this parameter can be parameter for LinqDataSource's where:
<asp:LinqDataSource ID="_LinqDataSource" runat="server"
ContextTypeName="YourWebApp.DBDataContext"
TableName="SomeTable"
Where="foreignID == Guid(@foreignID)" Read more:passed
Inappropriate name of DetailsView in msdn 0000-00-00 00:00:00 This article is for fun. When I opened msdm for VS 2008 and I read for LinqDataSource's EnableInsert Property I found that in examlpes:
The ID of DetailsView is named 'GridView1', but the suitable name should be 'DetailsView1'. By default when create DetailsView from ToolBox, the ID for it by default is 'DetailsView1'. So, I guess in the example first is written GridView, but later it h
ContentPlaceHolder in title tag, Is That Bug in VS 2008 ? 0000-00-00 00:00:00 I faced with strange problem: In my asp.net app, I've master page and aspx page that inherits the masterpage.
In masterpage I've that code:
<title>SITE TITLE - <asp:ContentPlaceHolder ID="_subTitleContentPlaceHolder" runat="server"></asp:ContentPlaceHolder></title>
I've text 'SITE TITLE - ' that will be visible in title tag of every page, and after tha
Why should we use ResolveUrl 0000-00-00 00:00:00 Let's look at this scenario:
We have site with folder:
SiteFolder
|-Admin // folder
| |-page2.aspx; // page that inherits main.master
| -main.master // main master page
| -page1.aspx; // page that inherits main.master
| -style.css // css
in site folder we've Master Page(main.master) and to pages(page1.aspx and page2.aspx) that inherits from it.
Dif
Guid.TryParse in Framework 3.5 0000-00-00 00:00:00 Unfortunately, method Guid.TryParse(string s, out Guid result) doesn't exist in .net, event in Framework 3.5 :(
But it's easy to write our method which tries to parse Guid:
Example 1:
bool TryParseGuid(string s, out Guid result)
{
bool parseResult = false;
result = Guid.Empty;
try
{
result = new Guid(s);
parseResult = true;
}
Redirect to current page 0000-00-00 00:00:00 You can redirect to current page without even know page's name( ex. in ascx controls ).
in aspx or ascx page:
<a href='<%= Request.Url.AbsoluteUri %>'> Some Text </a>
Request.Url.AbsoluteUri returns FULL url. For exaple if we open page " Request.Url.AbsoluteUri will return full url string with paramters.
But If we want short url( ex. /Default.aspx ) we must use Request.Ur Read more:Redirect
Validate Max Length of TextBox's text 0000-00-00 00:00:00 It's good to validate maximum length of a textbox's content. There're many ways for doing that. In our oppinion best way for doing that is with Regular Expression:
<asp:TextBox ID="_someTextBox" runat="server" />
<asp:RegularExpressionValidator ID="_validateMaxLen"
runat="server" Display="dynamic"
C Read more:Length
, Validate
Highlight text in GridView using javascript 0000-00-00 00:00:00 Sometimes it's a good idea to highlight some text in the page. We use it when search to highlight the seaching words in the result(for presenting result we use GridView):
Read more:Highlight
Optimize Page Loading - 20 General Tips and Tricks 0000-00-00 00:00:00 Here's list of general tips to speed up the loading time of your pages.
1. Use Browser Cache
When visit page for first time, Browser have to download all resource Read more:General
, Loading
what is asp.net 0000-00-00 00:00:00 *This article is for visitors of the site, who are not familiar with asp.net
ASP.NET is a web application framework developed and marketed by Microsoft,
Why Client Validation is not enough to secure our web app 0000-00-00 00:00:00 We all use asp.net validators (RequiredFieldValidator, CompareValidator, RangeValidator, RegularExpressionValidator, CustomValidator, Validation
Summary) and it's good to use them BUT they will not Read more:Client
Optimize Page Loading when works with DataBase 0000-00-00 00:00:00 I think that speed of loading of site is something very important. If you don't pay attention on site loading, it may cause many problem:
1) many people won't come back to the site (who can Read more:Loading
Screw it, Let’s RE-Design it all 0000-00-00 00:00:00 When started the site, there was something in the design that I didn't like, but I couldn't understand exactly what was the problem. So, I make 3 different tries to make the design better, but with Read more:Screw
Additional ASP.NET AJAX Libraries 0000-00-00 00:00:00 Additionaly to ASP.NET AJAX
, many third-party AJAX libraries are available that can be used with ASP.NET. Some are mostly focused on providing JavaScript libraries for use from within the browser t Read more:Libraries
The Big Problem of WYSIWYG Editors 0000-00-00 00:00:00
You use WYSIWYG
editors in your web apps, don't you ?
I added into current site standard and popular WYSIWYG editor, it was cool as design but there was a problem - it really Read more:Editors
, Problem
10 Design Tips 0000-00-00 00:00:00 1. Use Only Five to Seven Main Categories
Five and seven are magic numbers in life because remembering a list of five
to seven things is easy. Any more than that a