简体   繁体   中英

accessing html control inside the page from web user control

I have created a web user control I want to change the iframe' src value when the user click on the link but the problem is that I dont have access to iframe inside the page from web user control I think there is a way because my control is in the page they have some relation perhaps I like to find something like this :

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

How about doing it in javascript? You will save a whole unnecessary postback to the server...

You can use the following jQuery code to change the src attribute.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM