开发者

ASP MVC 2 Dynamic Href By Javascript

开发者 https://www.devze.com 2023-01-12 09:38 出处:网络
Here is the deal: My link: <li><% =Html.ActionLink(\"Scheme\", null, null, null, new { @id = \"schemeid\" })%></li>

Here is the deal:

My link:

<li><% =Html.ActionLink("Scheme", null, null, null, new { @id = "schemeid" })%></li>

JavaScript for changing href:

<script>
    开发者_运维知识库document.getElementById('schemeid').href= "Test/ALL";
</script>

Its working in any browser on ASP.NET dev.server on vs2010; but when i host it on iis 7. it fails. and in source of web page i have href=""

can any one help?


First of all, try using Firefox and check "Console Errors" to see if you got any javascript error. Second, try this:

<script>
    $(document).ready(function () {
        document.getElementById('schemeid').href= "Test/ALL";
    });
</script>

You'll need jQuery. Maybe your script is executing before rendering the tag.


found solution. thx to every body. here is answer:

document.getElementById('list').innerHTML='<% =Html.ActionLink("Scheme","ALL","Test")%>';

<li id="list"><% =Html.ActionLink("Scheme", null, null)%></li>    
0

精彩评论

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