tags:

views:

17

answers:

1

hi
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;
}

A: 

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');
};
Jakub Konecki
How I can implement that ? jquery using json please tell me more
kamiar3001
unfortunatly Ids are generated dynamicly in the gridview and this is not correct in this situation
kamiar3001
So instead use 'ends with' selector or a css class, or any other selector that suits you
Jakub Konecki