开发者

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 开发者_StackOverflowthe 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');
};
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜