asp.net - How to control usercontrol from javascript -


I have a user control with an attribute targetUrl; I add control to this user on one page and below this page Like the targetUrl attribute I type:

    

It worked correctly, but I want to change the targetUrl attribute with javascript. And I can not do this, I write a code like the one below but it does not work.

  var frm = document.getElementById ('Modal1'); Frm.targetUrl = 'pop_adres_giris.aspx';  

How can I do this?

User control object, which generates HTML on the client side, is not available as rich objects Which are available on handling server-side calls.

Depending on what UserControl is, you must use a different method to achieve it "TargetUrl".

In addition, you want to easily access the elements inside the Dome, you may want to consider using a library such as jQuery or prototype

For example, If you were using ASP: hyperlink control:

  & lt; Div id = "hyperlink_holder" & gt; & Lt; Asp: hyperlink ... navigate = url = "http: // someurl" /> & Lt; / Div & gt;  

You know that ASP: hyperlink HTML like & lt; Generates a href = "http: // someurl" ... />

Then we can access the element and change the link like this:

  $ ('# hyperlink_holder a'). Attr ("href", "http: // newurl"); Also, keep in mind that the IDs that you give an item in ASP.NET are not necessarily an ID that is presented in HTML in the IT element; Instead it is a combination of many IDs; Therefore, use selectors based on non-run = "server" controls, or pass ClientID of UserControl through a customer to use for selection if necessary. 


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -