Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Mobile > custom control help

Reply
Thread Tools

custom control help

 
 
Ferruccio Barletta
Guest
Posts: n/a
 
      10-21-2007
Hi,

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>
<msmobileocViewer 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.Co okielessData">
<device name="MicroSearchHtmlDeviceAdapters"
inheritsFrom="HtmlDeviceAdapters"

predicateClass="System.Web.UI.MobileControls.Adapt ers.HtmlPageAdapter"
predicateMethod="DeviceQualifies"

pageAdapter="System.Web.UI.MobileControls.Adapters .HtmlPageAdapter">

<control name="MicroSearch.MobileControls.DocViewer,msmobil e"

adapter="MicroSearch.MobileControls.Adapters.HtmlD ocViewerAdapter,msmobile"/>
</device>
</mobileControls>


Everything builds just fine, then I run it and get:
-----------------------------

Server Error in '/MobileWS' Application.
--------------------------------------------------------------------------------

MicroSearch.MobileControls.Adapters.HtmlDocViewerA dapter..ctor()
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.MethodAccessException:
MicroSearch.MobileControls.Adapters.HtmlDocViewerA dapter..ctor()

Source Error:


[No relevant source lines]


Source File: c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temp orary
ASP.NET Files\mobilews\baf280a3\14ea269b\App_Web_gn20izer. 0.cs Line: 0

Stack Trace:


[MethodAccessException:
MicroSearch.MobileControls.Adapters.HtmlDocViewerA dapter..ctor()]
T_6e0ac78c_f36d_4b8f_86bc_f9657d47809a.CreateInsta nce() +0

System.Web.UI.MobileControls.IndividualDeviceConfi g.NewControlAdapter(Type
originalControlType) +12

System.Web.UI.MobileControls.MobilePage.GetControl Adapter(MobileControl
control) +38
System.Web.UI.MobileControls.MobileControl.get_Ada pter() +38
System.Web.UI.MobileControls.MobileControl.OnUnloa d(EventArgs e) +22
System.Web.UI.Control.UnloadRecursive(Boolean dispose) +267
System.Web.UI.Control.UnloadRecursive(Boolean dispose) +204
System.Web.UI.Control.UnloadRecursive(Boolean dispose) +204
System.Web.UI.Page.UnloadRecursive(Boolean dispose) +20
System.Web.UI.Page.ProcessRequestCleanup() +40
System.Web.UI.Page.ProcessRequest(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +213
System.Web.UI.Page.ProcessRequest() +86
System.Web.UI.Page.ProcessRequestWithNoAssert(Http Context context) +18
System.Web.UI.Page.ProcessRequest(HttpContext context) +49
ASP.search_aspx.ProcessRequest(HttpContext context) in
c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temp orary ASP.NET
Files\mobilews\baf280a3\14ea269b\App_Web_gn20izer. 0.cs:0

System.Web.CallHandlerExecutionStep.System.Web.Htt pApplication.IExecutionStep.Execute()
+303
System.Web.HttpApplication.ExecuteStep(IExecutionS tep step, Boolean&
completedSynchronously) +64




--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.832;
ASP.NET Version:2.0.50727.832



Any ideas as to what's going on?

Thanks,
FGB
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Custom control within a custom control J R M ASP .Net 2 06-01-2006 06:04 PM
Capturing event from other custom control within another custom control Jonah Olsson ASP .Net 1 04-05-2005 01:39 PM
Capturing event from other custom control within another custom control Jonah Olsson ASP .Net Web Controls 2 04-05-2005 12:56 PM
ControlDesigner not invoked on custom control when control is rendered within another custom control Matt Sokol ASP .Net Building Controls 2 08-07-2003 07:13 AM
Using Table control in a custom composite control. Control does not render properly in design time. jb_in_marietta@yahoo.com ASP .Net 0 07-01-2003 09:26 PM



Advertisments
 



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