簡體   English   中英

從Web用戶控件訪問頁面內的html控件

[英]accessing html control inside the page from web user control

我創建了一個Web用戶控件,我想在用戶單擊鏈接時更改iframe的src值,但是問題是我無法從Web用戶控件訪問頁面內的iframe,我認為這是有辦法的,因為我的控件在頁面中他們有某種關系,也許我想找到這樣的東西:

public void On_WebUserControl_LinkButton_Click(object sender, EventArgument e)
{
    HtmlControl iframe = (HtmlControl) MainPage.findcontrol("myFrameName");
    iframe.attribute["src"] = mystringsrc;
}

在javascript中呢? 您將把整個不必要的回發保存到服務器...

您可以使用以下jQuery代碼更改src屬性。

$('#idOfYourButton').click(function() {
    $('#idOfYourIframe').attr('src', 'the new url');
};

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM