开发者

anchor text onclick to c# function

开发者 https://www.devze.com 2023-01-26 20:58 出处:网络
i have an iframe that which source need to be updated and refreshed. the way i want to do it is to click on anand with it\'s onclick function, i need to send something like myiframe.Attributes[\"src\"

i have an iframe that which source need to be updated and refreshed. the way i want to do it is to click on an and with it's onclick function, i need to send something like myiframe.Attributes["src"开发者_StackOverflow社区] = "blah.aspx";

is there any quick way to do this?

thanks in advance


You can use javascript to send an AJAX query back to the server with the frame's source.

The javascript you could use is iframe.location.href where 'iframe' is the id attribute of your iframe.

Then you can send a callback to the server using ASP.NET AJAX (or another ajax call if you wish). Here is a good tutorial: http://ajax.net-tutorials.com/


You could do it all client side if you wanted to (untested code):

...
<body>

    <a id="yourAnchorId">Load It</a>

    <iframe id="youriFrameId" src="blank.html" width="500" height="400"></iframe>

    <script type="text/javascript">

        document.getElementById('yourAnchorId').onclick = function() {
            var frame = document.getElementById('youriFrameId')
            frame.src = "blah.aspx;"
            frame.location.reload();
        };

    </script>

</body>
...
0

精彩评论

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