custom control help

custom control help

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


i,

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
{
get
{
Debug.WriteLine("get url: " + url_);
return url_;
}
set
{
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
{
get
{
Debug.WriteLine("new DocViewer");
return (DocViewer)base.Control;
}
}

public override void Render(HtmlMobileTextWriter writer)
{
Debug.WriteLine("Render");
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="http://www.w3.org/1999/xhtml">
<body>
<mobile:Form ID="SearchForm" Runat="server">
<mobile:Label ID="Label" Runat="server"
Alignment="Center">Search</mobile:Label>
<mobile:TextBox ID="SearchText" Runat="server" Alignment="Center"
OnTextChanged="SearchText_TextChanged"></mobile:TextBox>
<mobile:Command ID="SearchCmd" Runat="server" Alignment="Center"
OnClick="SearchCmd_Click">Search</mobile:Command>
<mobile:Label ID="ErrorMsg" Runat="server" ForeColor="Red"
Alignment="Center" BackColor="White"></mobile:Label>
</mobile:Form>
<mobile:Form ID="ResultsForm" Runat="server">
<mobile:List ID="ResultList" Runat="server" DataTextField="Text"
DataValueField="Value"></mobile:List>
</mobile:Form>
<mobile:Form ID="ViewForm" Runat="server">
<mobile:Label ID="Title" Runat="server" BackColor="LightCyan"
ForeColor="Blue"></mobile:Label>
<msmobile:DocViewer ID="DocumentViewer" Runat="server"
Visible="True" />
</mobile:Form>
</body>
</html>

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

<mobileControls sessionStateHistorySize="6"
cookielessDataDictionaryType="System.Web.Mobile.CookielessData">
<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;
wc.style |= 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)