編集用の新しい URL を開くか、編集 URL の (jquery ダイアログを介して) モーダル ウィンドウを開く可能性のある編集ボタンを持つ GridView 派生コントロールを構築しています。問題は、モーダルウィンドウを開くjavascriptが起動していないことです(起動している可能性がありますが、ポストバックのために表示されませんが、console.logが表示されないため、起動していないと思います)。
JavaScriptコードは正しいです。コンソールに貼り付けると、期待どおりに動作します。
だから、これはサブの私のコードです:
Protected Shadows Sub RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles MyBase.RowCommand
If e.CommandName = "EditInForm" Then
If Not FormularioModal Then
HttpContext.Current.Response.Redirect(url_edicion, True)
Else
'Must open a modal windows, registers JS to open dialog
Dim scriptModal As String = scriptAbreModal(url_edicion) 'This function creates correct javascript
log.log(String.Format("Registering {0}", scriptModal))
Dim page As Page = HttpContext.Current.Handler
Dim nombreScript As String = "scrAbreModal" & Guid.NewGuid().ToString().GetHashCode().ToString("x")
Dim cstype As System.Type = page.GetType
Dim cs As ClientScriptManager = page.ClientScript
If (Not cs.IsClientScriptBlockRegistered(cstype, nombreScript)) Then
cs.RegisterStartupScript(page.GetType, nombreScript, scriptModal)
End If
End If
End If
RegisterClientScriptBlock
(の代わりにも試してみましたRegisterStartupScript
)
記録のために、生成された JavaScript コードは次のとおりです。
<script type="text/javascript">
var miVentanaModal;
miVentanaModal = $('<iframe id="iGridViewModalIFrame" src="q_pregunta_elementodoc.aspx?op=upd&id=28&pregunta=6&modal=true" />')
.dialog({ title: 'Title',
autoOpen: true,
width: 575,
height: 320,
modal: true,
resizable: true,
autoResize: true,
overlay: { opacity: 0.5, background: "black" } }).width(555).height(300);
</script>
何か案は?
ありがとうございました
PS: このコードは純粋なコード クラスにあり、いくつかのコントロールとユーティリティを含む dll にあります。