Thursday, May 23, 2024
Homepage · c#
 Popular · Latest · Hot · Upcoming
42
rated 0 times [  48] [ 6]  / answers: 1 / hits: 19170  / 13 Years ago, fri, august 26, 2011, 12:00:00

I am attempting to run this JS function when a user clicks on a Panel (in a TableCell). This Panel is an element in a Content Page, which is used with the Master Page which has a Content Place Holder. When I try to click on the panel, the following error is thrown:



Microsoft JScript runtime error: Object doesn't support this property or method



Here is the relevant code for the Master page ASPX:



       <link rel=Stylesheet href=../includes/styles.css />
<script type=text/javascript language=javascript>
function swapDirections(control) {
var main = document.getElementByID('ct100_TableContent_' + control);
var long = document.getElementById('ct100_TableContent_' + control + '_long');
var short = document.getElementById('ct100_TableContent_' + control + '_short');

var mainhtml = main.innerHTML;
var longhtml = long.innerHTML;
var shorthtml = short.innerHTML;

if (mainhtml.length == shorthtml.length)
main.innerHTML = longhtml;
else
main.innerHTML = shorthtml;
}
</script>


Here is the relevant code for the Content page:



            Panel rigDirections = new Panel();
rigDirections.CssClass = clip;
rigDirections.ID = u.Id.ToString() + _RD;
string MainDivRD = rigDirections.ClientID;
Literal rigDir = new Literal();
string sshort = ;
if (u.RigDirections.ToLower().Length > (textCutOFF + 4))
{
sshort = Server.HtmlEncode(u.RigDirections.ToLower().Substring(0, textCutOFF).Trim()) + ...;
rigDir.Text = <a class=RD_RA title=Click to Expand href=javascript: swapDirections(' + MainDivRD + ')> + sshort + </a>; ;
}
else
{
sshort = Server.HtmlEncode(u.RigDirections.ToLower().Trim());
rigDir.Text = sshort ;
}
string slong = Server.HtmlEncode(u.RigDirections.ToLower().Trim());

rigDirections.Controls.Add(rigDir);
cell.Controls.Add(rigDirections);


And the Content Page ASPX:



      <asp:Content ID=Content1 ContentPlaceHolderID=TableContent Runat=Server>

<asp:Panel ID=pnlTable Width=950 runat=server>

</asp:Panel>
</asp:Content>


The error is being thrown on the first line of the function.



I have exhausted my internet searching skills, and I have never used JS before, so if anyone has any ideas I would greatly appreciate them.



Thanks!



badPanda


More From » c#

 Answers
21

javascript is case sensitive. document.getElementByID() is not a function, but document.getElementById() is.


[#90393] Thursday, August 25, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
rayvenc

Total Points: 666
Total Questions: 125
Total Answers: 99

Location: Northern Ireland
Member since Mon, Nov 14, 2022
2 Years ago
rayvenc questions
Tue, Apr 21, 20, 00:00, 4 Years ago
Mon, Apr 13, 20, 00:00, 4 Years ago
Sun, Mar 1, 20, 00:00, 4 Years ago
;