[RESOLVED]Access view control from partial view

Hi, how would I access a view control like a div and set its innerhtml or innertext with data from a partial view ? I know I would do it like this in a web form with javascript :

function cbChange(val) {
var namesTocheck = document.getElementById(‘labNames’).innerHTML.toString()+val;
document.getElementById(‘tabs’).innerHtml = val.toString();
}

But this doesn’t seem to work when I try call it for an onclick event on a html button when that button and value are in a partial view.

How would I do this correctly, any help is much appreciated :)

garethcarver

But this doesn’t seem to work when I try call it for an onclick event on a html button when that button and value are in a partial view

some javascript error?

No javascript error, just seems like it doesnt even see the control, firebug didnt pick up a thing and when it executes the control value in the main view doesnt change at all 

I suspect you are not using the proper ids. Please post your code. Also include the generated html of those controls you need to change the value

Hi garethcarver,

Please provide the detail code.

As pprasannak said that you may not use the proper ids.

You could use the developer tool to debug the JavaScript code.

You code could be like this:

<button onclick="cbChange(‘test’)">my button</button>

<div id=”labNams”>Name</div>

<div id=”tabs”> tabs</div>

Best Regards

Starain Chen

garethcarver

how would I access a view control like a div and set its innerhtml or innertext with data from a partial view ?

When do want access the elements of main view in partial view?

Leave a Reply