custom control help

custom control help

Post by Ferruccio » Mon, 22 Oct 2007 23:07:05


I've been building a mobile custom web control using MSDN and various
articles as a guide. The purpose of the control is to retrieve a
document at a url and display its contents. Right now, I would be happy
if I could get it to simply display a fixed string!

So, I created a control:
using System;
using System.Web.UI;
using System.Web.UI.MobileControls;

using System.Diagnostics;

namespace MicroSearch.MobileControls
public class DocViewer : MobileControl
private string url_ = "";

public String Url
Debug.WriteLine("get url: " + url_);
return url_;
url_ = value;
Debug.WriteLine("set url: " + url_);

and a control adapter for html devices:
using System;
using System.Web.UI.MobileControls;
using System.Web.UI.MobileControls.Adapters;
using System.Diagnostics;

namespace MicroSearch.MobileControls.Adapters
class HtmlDocViewerAdapter : HtmlControlAdapter
protected new DocViewer Control
Debug.WriteLine("new DocViewer");
return (DocViewer)base.Control;

public override void Render(HtmlMobileTextWriter writer)
writer.Write("I am here!");

the control and the adapter are built into an assembly: msmobile.dll
which is then referenced by the application:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Search.aspx.cs"
Inherits="Search" %>

<%@ Register TagPrefix="mobile" Namespace="System.Web.UI.MobileControls"
Assembly="System.Web.Mobile" %>
<%@ Register TagPrefix="msmobile" Namespace="MicroSearch.MobileControls"
Assembly="msmobile" %>

<html xmlns="">
<mobile:Form ID="SearchForm" Runat="server">
<mobile:Label ID="Label" Runat="server"
<mobile:TextBox ID="SearchText" Runat="server" Alignment="Center"
<mobile:Command ID="SearchCmd" Runat="server" Alignment="Center"
<mobile:Label ID="ErrorMsg" Runat="server" ForeColor="Red"
Alignment="Center" BackColor="White"></mobile:Label>
<mobile:Form ID="ResultsForm" Runat="server">
<mobile:List ID="ResultList" Runat="server" DataTextField="Text"
<mobile:Form ID="ViewForm" Runat="server">
<mobile:Label ID="Title" Runat="server" BackColor="LightCyan"
<msmobile:DocViewer ID="DocumentViewer" Runat="server"
Visible="True" />

and finally I added a device adapter entry in the app's web.config file:

<mobileControls sessionStateHistorySize="6"
<device name="MicroSearchHtmlD

1. DateTime Picker Custom Control Help

2. *Custom Control Help! Using a classic C-Style custom control.*

*Custom Control Help! Using a classic C-Style custom control.*

Hello, I am attempting to port a classic C-style custom control into
a .net application.

Using Visual Studio 6,
This was originally done via the resource files in the project, using
a "CustomControl" item in the resource editor, and pointing the
"windowclass" to the specific class name of the developed custom
control. I would like to get the .net flexibility.

This window class is registered in the dll using the following code:

wc = Template; |= CS_DBLCLKS;
wc.lpfnWndProc = RecordingWndProc;
wc.lpszClassName = PCS_RECORDING_CLASS;
if (!RegisterClassEx(&wc))
return FALSE;

As you see, it is very 'legacy'. I am attempting to use this in c++,
without the assistance of mfc. A nice user control or regular control
solution would be preferrable, I am trying to use the *.rc resource
stuff. Any help or direction?

In the usercontrol and regular control classes, I cannot find any way
to link the classes with the actual control (a graph control developed
by our company).

3. ControlDesigner not invoked on custom control when control is rendered within another custom control

4. help needed to create custom control which can arrange controls in polygonal shape

5. Capturing event from other custom control within another custom control

6. zooming a custom control - layout custom controls in grid

7. Custom control within a custom control

8. Custom Control : One custom property to array of controls

9. databound custom controls vs composite databound custom controls

10. Blend and custom controls derived from custom base control class.

11. Capturing event from other custom control within another custom control

12. Custom Control inheriting from a Custom Control

13. COMPILE ERROR when using custom controls w/ custom properties w/ custom TypeConverters

14. Controlling html/xml tag of custom control from control code

15. Creating custom controls out of more complex control types (eg change password control)