@bobnoordam

Category: ASP.NET Webforms

Maintaining vertical scroll position on an ASP.NET GridView across postbacks

Our mission Here is what we want to archieve with a standard ASP.NET gridview; We want scroll bars to scroll vertical in a potential long list When a row is selected in the gridview, we want to maintain the scroll position in gridview. (de default behaviour would be for the grid to jump back up to the top of the list When the user navigates away and comes back, we want the scroll state to […]

Securing session cookies in asp.net

Securing session cookies by itsself is very straightforward. By adding the following markup to the system.web section in web.config your session cookies will no longer function without https. <httpCookies requireSSL=”true” /> However, this will give you a new problem if you run in a test environment or debug session without https. Since the cookie will no longer work, neither will your site. Here come transforms to the requeue. Since VS 2010 each web.config has two […]

Raising an event on a usercontrol, and subscribing to it from an ASPX page

This is a minimalistic demonstration on hooking into an event risen by a usercontrol. The main page subscribes to the event on the user control, and once the usercontrol raises a postback the event data is retrieved. User control code using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace UsercontrolEvents { public partial class WebUserControl1 : System.Web.UI.UserControl { public delegate void SendEventHandler(string message); protected void Page_Load(object sender, EventArgs e) { } […]

Passing data to an SqlDataSource on a user control from code

This code snippet demonstrates how to programmaticaly set a parameter on a user control, and bind that paramter to an SqlDataSource that has been configured at design time. The key to this functioning is a method in the usercontrol that sets a private field on the user control, and triggerin the DataBind() event on the GridView (causing the SqlDataSource to execute it’s query). The query has the SqlDataSource1_Selecting event set to fill in the paramter […]

ASPxImageSlider – Resize slider for different devices

This code sample shows how to resize the ASPxImageSlider control for different devices and screen resizing. (thing rotating your tablet). The slider exposes a client side ID (ClientInstanceName = “imageSlider”) which can be hooked into with a little javascript. While this solves the basic problem, of having the slider react to different screen sizes, you are basically forced to operate with maximum size images, and have the control crop the images back to the smaller […]

Scaffolding for an ASPxGridView with Select button using custom callbacks

Emulates the behaviour of the standard webforms grid, with a view where each line has a button that can be used to ‘select’ that line. This should make transition from the built in gridview to de ASPxGridView very easy. The click is processed server side It is not possible to select more then one line The selected line will be highlighted Note that the “KeyFieldName” propert ius used to provide the line id in the […]

Page and control level validation using javascript with asp.net

This sample is a complete minimal implementation of client side verification of inputs before a pass to the server is made. Verification is done on control level with the onblur() event, and on page level when the form is submitted. This validation is faster then round-tripping to the server for each event, especialy with large complex pages with a lot of controls. The downside is additional code (javascript) in the markup section of your pages. […]

Accordeon control

The accordeon control is part of the Ajax control toolkit and offers a series of tab-like sections, of which one is expanded at a time. Below is a minimal use sample of how to deploy the control. The ajax control toolkit can easily be installed from the NUGET menu within visual studio. Markup <%@ Page Language=”C#” AutoEventWireup=”true” CodeBehind=”Accordion.aspx.cs” Inherits=”AjaxToy.Accordion” %> <!DOCTYPE html> <html xmlns=”http://www.w3.org/1999/xhtml”> <head runat=”server”> <title></title> <link href=”d/css/AjaxControlToolkit.css” rel=”stylesheet” type=”text/css” /> </head> <body> <form […]

Testing the Ajax Control Toolkit Tab control with WatiN

The Ajax Control Toolkit offers a large amount op ASP.NET Ajax control, and can be found on codeplex. WatiN is a popular test framework for UI testing ASP.NET web applications. Both can be obtained from the linked site, or can easily be added in Visual Studio with nuget. The objective of this writeup is to use WatiN to start an IE session, fire up a local website with the tab control on it, and proceed […]

Dropdown menu’s with ASP.NET and JQuery

This sample shows how to setup a basic JQuery popdown menu embedded in an asp.net webforms application, and how to position it correctly under your menu bar. As you will discover, no code behind at all is needed to make the basic functionality work, so no need for postbacks and displaying and hiding panels. The framework for displaying and hiding the menu is 100% html, css and jquery. The actual content in to show in […]

Next Page » « Previous Page