問題タブ [servercontrols]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票する
2 に答える
1582 参照

asp.net - asp.net カスタム サーバー コントロール - このコントロールが原因でポストバックが発生したかどうかを確認する方法

カスタムasp.netサーバーコントロール(実際にはチェックボックスの特殊バージョン)があります。ポストバックで何らかの処理を行いたいのですが、ポストバックがこのコントロールがクリックされた結果である場合に限ります (autopostback が true に設定されています)。ポストバックがこのコントロールの結果なのか、それ以外の結果なのかを判断する最善の方法は何ですか?

ご協力いただきありがとうございます。

0 投票する
3 に答える
4483 参照

asp.net - asp.net リピーターのサーバー コントロール

ここで壁にぶつかったようです。一部のデータソースをasp.netリピーターにバインドしたい(まあ、リピーターである必要はありませんが、それが私が望んでいるようです)。さて、問題は次のとおりです。データ (TextBox とボタン) を更新するために、そのリピーター内にいくつかのサーバー コントロールも必要です。

私の理解では、これは整然とした方法で行うことは本当に可能ではありませんか? itemtemplate にテキストボックスを追加して、後でコード ビハインドで取得することはできません。少なくとも簡単ではありません。この種の問題に対する既知の手法はありますか?

データを特定の方法でフォーマットする必要があるため、グリッドビューを使用できません。

0 投票する
4 に答える
3775 参照

asp.net - javascript から asp:Image にアクセスするには?

次のように、サーバーマークアップに asp:Image を取得しました。

今、私は自分のjavascriptでこのimgを見つけたいと思っていますが、ASP.Netが私の名前を難読化するという問題に遭遇しているようです。client-markup は次のようになります。

これは、すべてが「コンテンツ」と呼ばれるフォーム要素内にあるためだと思いますが、これはごく普通のことだと思いますか? :)

javascript からこれにアクセスする方法についての指針はありますか?

[編集] javascript の "servertime" を変更して難読化された ID を検索する簡単な方法があるかどうか考えていました。

0 投票する
3 に答える
1594 参照

asp.net - コード ビハインド プロパティ値をサーバー コントロールに宣言的に渡す方法はありますか?

ASP.Net のサーバー コントロール宣言内でインライン コード ブロックを使用できない理由を誰か説明できますか?

以下は簡単な例です...

コードブロックは文字通りページにレンダリングされます...

私の最初の考えでは、ページのライフサイクルでこれらが処理される順序に関係しているということです。ブロックは、私が理解しているように、分離コード<%=...%>に相当します。Response.Write(...)また、サーバー コントロールは実際にはマークアップで宣言されているとおりにはレンダリングされないため、このレンダリングが行われる前に埋め込みコード ブロックを処理できない可能性があると思います。

誰かがそれをもう少しうまく説明できることにとても感謝しています。

ただし、データ バインディング コード ブロックの<%#...%>動作は明らかに異なりますが、サーバー コントロール内にこれらを埋め込むことができる理由を誰か教えてください...

これはうまくいきます。

0 投票する
2 に答える
1261 参照

asp.net-mvc - ASP.NET MVC の PostBack でサーバー コントロールを使用する方法は?

ボタンをクリックすると、「viewstate MAC の検証に失敗しました」という例外がスローされます。MVC が PostBack をサポートしていないことは知っていますが、これを回避する方法はありますか?

または、MVC で HtmlHelper を使用する必要がありますか?

以下はViewでの私のコードです:

0 投票する
1 に答える
846 参照

asp.net - ASP.NET サーバー コントロール: デザイン時の文字列をオブジェクト型に変換する方法 (TypeConverter?)

うまくいけば、これはばかげた質問です (簡単に答えられるはずです)。

必要なフィールドのタイプに応じて、TextBox、いくつかのバリデーター、その他のものをカプセル化する複合サーバー コントロールを作成しようとしています。

私のコントロールには、何を表示するかを決定できる「DataType」値があります。たとえば、DataType が「Date」の場合、AjaxControlToolkit.CalendarExtender などをレンダリングします。

私の一般的な「Value」プロパティはオブジェクトであり、DataType プロパティが要求するものは何でも返すため、上記の例では、Value は Date 型になります。

ここに私の問題があります。受信した Value プロパティを、実行時に DataType が要求するものに変換する必要があります。

ご覧のとおり、 TypeConverter を作成しようとしましたが、うまくいかないようで、コンパイル中に次のエラーが発生します。

タイプ 'System.Object' の値のコードを生成できません。このエラーは、Value のプロパティ値を生成しようとしたときに発生しました。

どんな助けでも大歓迎です!

コントロールを呼び出そうとする方法は次のとおりです。

これが私のクラスです:

0 投票する
1 に答える
240 参照

javascript - サーバーコントロールがコールバックでmousedownイベントハンドラーを失う

Renderメソッドで右クリックイベントハンドラーをアタッチするdivを含む複合サーバーコントロールがあります(わかりやすくするために簡略化されています)。

サーバーコントロールは、aspxページの更新パネル内に配置されます。

最初のページの読み込み後はすべて問題ありませんが、updatepanelがコールバックを実行するとすぐに、イベントハンドラーが失われます。関数を変更して、関数内のコードがないことを証明するアラートを実行するようにしました。

サーバーコントロール自体は、次のように宣言されます。

なぜこれが起こっているのか、私は本当に途方に暮れています...何か手がかりはありますか?

0 投票する
3 に答える
2217 参照

asp.net - ASP.NET、アンカータグ付きのイベントハンドラーの背後にあるコードをトリガーする

アンカータグを使用して、イベントハンドラーのコードビハインドを呼び出すことは可能ですか?いろいろ試してみましたが、うまくいかないようです。

私は次のようにタグを書いてみました:

成功せず...

何か案は?

0 投票する
1 に答える
379 参照

asp.net - ページに IE8 ネイティブ モードのコントロールが多数ある場合、ASP.NET イベント ワイヤリングが正しく機能しない

まあ、ネイティブ モードの IE8 は ASP.NET イベント ワイヤリングを好まないようです。ASP.NET 2.0 で開発された重いページはほとんどありません。重いとは、サーバー コントロールとコールバック コントロールがたくさんあることを意味します。最後のアクションは Apply と Cancel ですが、ユーザーは Callback 呼び出しを通じてコン​​トロールのデータを設定します。

[適用] ボタンをクリックすると、Page_load、init などの標準の ASP.NET ページ イベントが複数回呼び出されることがわかりました。その結果、機能が期待どおりに機能しません。これらのページは、アプリケーションが IE7 または IE8 (IE7 エミュレート モード) で起動されたときに問題なく動作します。

巨大で独自仕様であるため、コードを添付することはできません。IE8 から起動した ASP.NET アプリで同様の問題に遭遇した人がいるかどうか疑問に思っています。

ポインタに感謝します。

ありがとう、ダナンジェイ

0 投票する
1 に答える
490 参照

.net - Web controls lifecycle problems: A page, a grid and a dialog (containing a dynamic control whose type depends on the selected row in the grid)

I have a web page with a GridView. The GridView contains a list of Question objects. Each Question has a QuestionType. When the user clicks on the Question control, an Ajax modal popup appears containing a Dialog custom web control. The Dialog web control is designed to encapsulate a child custom web control together with OK and Cancel buttons. In this scenario, the child control is a Question custom control that represents the selected Question. The exact type of the Question control is not known until a row in the GridView is clicked.

To sum up the page hierarchy:

  • Page
  • GridView containing questions (declared in the .aspx markup, fires an event when a row is clicked)
  • Panel linked to AJAX modal popup extender (declared in the .aspx markup)
  • Dialog control (declared in the .aspx markup)
  • Question control (created dynamically within the Dialog control, type not known until Question selection is made)
  • OK button (created dynamically within the Dialog control)
  • Cancel button (created dynamically within the Dialog control)

When the user clicks the OK button in the Dialog, I want to be able to get at the contents of the Dialog from the containing page. (There is code in the various Question controls that validates the answer and a property in the Dialog that exposes the answer to the containing page.)

I have been having large amounts of trouble in getting this to work.

I have been googling for hours and all articles about custom web controls state that you need to create child controls within the OnInit override. However, in my scenario, the Dialog OnInit method is called before GridView fires its row clicked event, meaning I can't create the Question control because I don't know the target type.

I can make it at least show the dynamic Question control if I move code that creates it to a later point in the lifecycle of the Dialog e.g. RenderContents. However, this is not correct according to all the articles and useless anyway because the control is still not available when the OK button in the Dialog is clicked (as the dialog is hidden and RenderContents will never be called).

So, I'm asking the ASP.NET guys on here how this is supposed to be done? I'm not looking for the code; just strategy. What is the correct way to set this up? The aim is a dialog that contains a dynamically created control whose type depends on the selected row in the GirdView and that can be accessed by the containing page after a postback.

Any tips would be greatly appreciated.

UPDATE

I added logging and the order of events firing after the grid is clicked is as follows:

  • Page ctor
  • Dialog ctor
  • Dialog OnInit
  • Page OnInit
  • Page CreateChildControls
  • Dialog CreateChildControls
  • Page OnLoad
  • Dialog OnLoad
  • Page OnContactorComplianceQuestionSelected
  • Dialog RenderContents

I only know what type of control the Dialog is supposed to contain after Page OnContactorComplianceQuestionSelected.