Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

asp:Dropdownlist onChange event not firing in IE but is in Mozilla 3

Status
Not open for further replies.

jelrod63

Programmer
Dec 26, 2006
10
US
I have an inline popup that has an asp:Dropdownlist that is NOT firing during the onChange event in IE but IS firing in Mozilla. Below is the my code. Any help would be greatly appreciated.

Code from my aspx page
Code:
<body>
<form id="upSellForm" runat="server">
<table border="0" cellspacing="0" cellpadding="0"> 
  <tr>
      <td>                        
      <asp:DropDownList id="upsellDescriptionDropdown" runat="server" onChange="javascript:showMe(this);">
      </asp:DropDownList>
      </td>
  </tr>
</table>
</form>

<script type="text/javascript">   
    function showMe(a)
	{       
        alert("Here I am");
	}
</script>
</body>
[code]
 
can u try just onchange="showMe(this);"

use all lower for the onchange

case sensitivity for IE, and no need to append the javascript: i think.
 
Thanks for the reply adamroof. I made the changes that you suggested but unfortunately it's still not working in IE. I'm getting the following error from IE: "Object expected
 
Have a look at what the rendered HTML is for that page as this will show what the problem is.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
howabout this...

move your javascript to the head tag
Code:
<head>
<script type="text/javascript"> 
function showMe(a)
{ 
alert("Here I am");
}
</script>
</head>
<body>
<form id="upSellForm" runat="server">
<table border="0" cellspacing="0" cellpadding="0"> 
<tr>
<td> 
<asp:DropDownList id="upsellDescriptionDropdown" runat="server" onChange="javascript:showMe(this);">
</asp:DropDownList>
</td>
</tr>
</table>
</form>
</body>
 
Thanks again for replying adamroof I tried what you said by putting the javascript in the head tag but I'm still getting the same error in IE.
 
To ca8msm:

Thanks for your reply ca8msm but when I try to view the rendered HTML from the inline popup I cannot do so to see what the problem is with my page. Any clue on how I can view source from an inline popup page?
 
Right click the page and use the view source option


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
This works for me in IE6 and IE7


Does it work for you?

Code:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="testingfile.aspx.cs" Inherits="testingfile" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]
<head>
    <title>Testing Page</title>

    <script type="text/javascript"> 
        function showMe(a)
        { 
            alert("Here I am");
        }
    </script>

</head>
<body>
    <form id="upSellForm" runat="server">
        <table border="0" cellspacing="0" cellpadding="0">
            <tr>
                <td>
                    <asp:DropDownList ID="upsellDescriptionDropdown" runat="server" onchange="showMe(this);">
                        <asp:ListItem Value="Select Me First"></asp:ListItem>
                        <asp:ListItem Value="Select Me Second"></asp:ListItem>
                        <asp:ListItem Value="Select Me Third"></asp:ListItem>
                        <asp:ListItem Value="Select Me Fourth"></asp:ListItem>
                    </asp:DropDownList>
                </td>
            </tr>
        </table>
    </form>
</body>
</html>
 
hi guys,

jelrod63 is a co-worker of mine, so I'm familiar with his issue. The problem is that his code works fine on a regular aspx page, but when he opens the page that holds this code using some inline javascript (an aspx as a pop up), the event doesnt fire.

I also think he isn't getting the right click option to view source, either.

thanks for your help so far !
T
 
adamroof

Thanks again for replying I really do appreciate it very much. I'm still getting the same error in IE: "Object expected" but when I changed the following the onchange event is being fired (Notice the part onchange="alert('Here I am')">):

<asp:DropDownList ID="upsellDescriptionDropdown" runat="server" onchange="alert('Here I am')">
<asp:ListItem Value="Select Me First"></asp:ListItem>
<asp:ListItem Value="Select Me Second"></asp:ListItem>
<asp:ListItem Value="Select Me Third"></asp:ListItem>
<asp:ListItem Value="Select Me Fourth"></asp:ListItem>
</asp:DropDownList>


That does me no good though because I need to be able to Javascript functions. Could it not be working because my code is in an inline popup and that is the reason it is not finding the object? I have to use an inline popup for this part of my project though. Now I'm really at a loss.
 
adamroof

here is the inline popup function you requested

var inlineObj = function(width, height, path, file, params, obj)
{
showAllSelects();
showFlash();

divWidth = width;
divHeight = height;
if (path != '')
url = "/" + path + "/_popups/" + file + "?" + params;
else
url = "/_popups/" + file + "?" + params;

getRequest(obj);
}


Below is a portion of my actual code from my summary.aspx.cs page which is calling the upsells.aspx page through the inline popup (***NOTE: 'upsells.aspx' is the page where the asp:DropDownList is located. The summary.aspx page is located in a folder called packages and the upsells.aspx page is located in a folder within packages in a folder called _popups)

StringWriter sw2 = new StringWriter();
HtmlTextWriter tw2 = new HtmlTextWriter(sw2);
tw2.Write("<td valign=\"top\" width=\"110\" align=\"right\">");
tw2.Write("<img src=\"/images/layout/arrow_orange.gif\">&nbsp;");
tw2.Write(" <a href=\"javascript:;\" onclick=\"javascript:inlineObj(330, 250, 'packages', 'upsells.aspx', 'showID=");
tw2.Write(node.SelectSingleNode("showID").InnerText);
tw2.Write("','showUpsellDetails");
tw2.Write(node.SelectSingleNode("showID").InnerText);
tw2.Write("');\" class=\"addTrip\">");
tw2.Write("add to my trip</a>&nbsp;&nbsp;</td>");
tw2.Write("</tr>");
tw2.Write("<tr>");
tw2.Write("<td valign=\"top\" colspan=\"2\" width=\"525\">");
 
recap:
so the page pops up okay, and it opens the aspx file, in which the onchange event doenst work unless you place the actual alert inside the event. hmmmm

i bet theres an error, but its just not showin in IE, and mozilla handles it properly, but IE is not. Is it a plain jane page like our examples? any other js getting in the way? maybe write out the js that opened the popup and see if theres any extra spaces or something.


updated to open a popup, the alert still happens, but the popup is not allowing another popup.

You can right click in the pop up and select View Source, but my example wont get you much.

changed
Code:
    <script type="text/javascript"> 
        function showMe(a)
        { 
            alert("Here I am, here comes a popup");
            window.open("testingfile.aspx","mywindow","status=0,toolbar=0,width=100,height=100"); 
        }        
    </script>
 
As adamroof has shown, there's nothing fundamentally wrong with the approach, it's the implementation that is the problem. We'll probably only find out the problem by being able to see what the browser sees.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top