使用webformユーザー制御webformにMVCプロジェクト
-
23-09-2019 - |
質問
を使用しているサーバーの制御単一ます。形。今まで使っていたこの制御に関す。形態のページでサーバー制御が実際にMVCます。うにしていただいています。形のフォルダとフォルダに入れが私の新しいページです。その後、コピーの例のコードの署名ます。を取得します以下のようなエラー:
The base class includes the field 'ctrlSign', but its type (WebSignatureCapture.SignatureControl) is not compatible with the type of control (ASP.signaturecapture_signaturecontrol_ctlsignature_ascx).
知っているコードの作品が取り出して、そのID属性にサーバーから管理ではなくこのエラーは、私の制御を描画します.すがさんありがとうございます。属性のIDで行うことができますがポスト事前登録の受付を開始しました。そのアイデアですが?
を使用してい この 署名ます。ところです。形式コー---
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Index.aspx.cs" Inherits="KahunaCentralTIDRevamp.SignatureCapture.Index" %>
<%@ Reference Control="~/SignatureCapture/SignatureControl/ctlSignature.ascx" %>
<%@ Register TagPrefix="uc" TagName="Signature" Src="~/SignatureCapture/SignatureControl/ctlSignature.ascx" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html>
<head>
<title>Signature Application Demo</title>
</head>
<body>
<form id="frmOrder" method="post" runat="server">
<div>
Please Sign Below:
</div>
<div>
<uc:Signature ID="ctrlSign" SignHeight="150" SignWidth="300" SignatureCodePath="~/SignatureCapture/SignatureControl/"
SavePath="~/SignatureCapture/" SignatureFileFormat="Gif" runat="server" />
<%-- <uc:Signature id="ctlMySignature" PenColor="Red" PenWidth="2" BackColor="Yellow" SignWidth="300" SignHeight="150"
SavePath="~/Signatures/" SignatureCodePath="~/SignatureControl/" SignatureFileFormat="Gif" Runat="server"></uc:Signature>--%>
</div>
<div>
<input type="button" value=" Re-Sign " onclick="ClearSignature();">
<asp:Button runat="server" ID="btnSave" Text=" Save " onmousedown="document.getElementById('btnSave').value = 'Wait...';"
OnClientClick="DirectSave();" OnClick="btnSave_Click" />
</div>
</form>
<script language="javascript" type="text/javascript">
// This is the method that is directly called, this will save signature
// and then call server code to do further processing. You can change
// the delay of 5 seconds as per your needs
function DirectSave() {
SaveSignature();
var date = new Date();
var curDate = null;
// delay of 5 seconds, 5000 milisecons, change as per requirement
do { curDate = new Date(); }
while (curDate - date < 5000);
return true;
}
</script>
</body>
</html>
解決
を開き、ユーザーコントロールのマークアップた.ascxファイル。それはこのような何かを読む必要があります:
<%@ Control
Language="C#"
AutoEventWireup="true"
CodeFile="ctlSignature.ascx.cs"
Inherits="WebSignatureCapture.SignatureControl.ctlSignature" %>
に変更してます:
<%@ Control
Language="C#"
AutoEventWireup="true"
CodeBehind="ctlSignature.ascx.cs"
Inherits="WebSignatureCapture.SignatureControl.ctlSignature" %>
お知らせCodeFile - 。>分離コード
他のヒント
誰か知っていたのと同じような問題が、その発見かしながら、何らかの BeginRequest ル問題、分かりやすく、感情表現としても利用サーバーの管理ます。思い切ってクイック検索していると考えている この は興味深く表現されています。
以下のコード:
void Application_BeginRequest(object sender, EventArgs e)
{
var form = HttpContext.Current.Request.Form;
form.GetType().GetProperty("IsReadOnly", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(form, false, null);
// Refinement 1:
foreach (var key in form.AllKeys.Where(key => key.Contains("$")))
{
var value = formkey;
form.Remove(key);
var newKey = key.Substring(key.LastIndexOf("$") + 1);
form.Add(newKey, value);
}
}
所属していません StackOverflow