我能够在打印它显示的页面中获取页面的所有控件的ID以及它们的类型
myPhoneExtTxt Type:System.Web.UI.HtmlControls.HtmlInputText
Run Code Online (Sandbox Code Playgroud)
这是基于此代码生成的
foreach (Control c in page)
{
if (c.ID != null)
{
controlList.Add(c.ID +" Type:"+ c.GetType());
}
}
Run Code Online (Sandbox Code Playgroud)
但现在我需要检查它的类型并访问其中的文本,如果它的类型为HtmlInput,我不太清楚如何做到这一点.
喜欢
if(c.GetType() == (some htmlInput))
{
some htmlInput.Text = "This should be the new text";
}
Run Code Online (Sandbox Code Playgroud)
我怎么能这样做,我想你明白了吗?
我使用jQuery生成按钮:
var button_a = $("<button />", {
text: 'A',
click: do_something,
class: "button a"
});
var button_b = $("<button />", {
text: 'B',
click: do_something,
class: "button B"
});
function do_something(){
alert("Button Was pressed");
}
Run Code Online (Sandbox Code Playgroud)
我想这样做do_something而不是:
function do_something(name){
alert("Button " + name + " was pressed");
}
Run Code Online (Sandbox Code Playgroud)
我应该如何改变jQuery的按钮创建,这样我可以在一传name的click: do_something?
是预先创建封闭的唯一解决方案吗?