hi,
can I open a dropdownlist of asp.net by server code?
(on asyncPostBack)
tanx.
sara.
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
amitPosted Sep 26, 2014, 5:09 AM
sara shatsPosted Jul 2, 2009, 9:35 AM
Page.ClientScript.RegisterStartupScript(This.GetType(), "", "openListElement(" + ddlUnder.ClientID + ");", True);
and put debugger on the javascript function but it didn't get in.
any idea?
Niradhip ChakrabortyPosted Jul 2, 2009, 9:00 AM
Use the following code in pagebehind where you want to call the function and write the javascript function in to of the page as it is shown below.
Page.ClientScript.RegisterStartupScript(this.GetType(), "", " openListElement(this);";", true);
// pass the instance of dropdownlist in onclick event
%@ Page Language="C#" AutoEventWireup="true" CodeFile="Reservation.aspx.cs" ClientTarget="uplevel"
Inherits="New_Reservation" EnableEventValidation="false" %>
DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>New Pagetitle>
<script type="text/javascript">
function openListElement(elementRef)
{
elementRef.size = elementRef.options.length;
}
script>
head>
<body bottommargin="0" topmargin="0" leftmargin="0" rightmargin="0">
<form id="frmReservation" runat="server">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr valign="top">
<td align="right">
td>
table>
form>
body>
sara shatsPosted Jul 2, 2009, 8:42 AM
it's not going to client side after, I tryed to put ScriptManager.RegisterStartupScript, but it didnt do it
(maybe its becose it's AsyncPostBack?)
Niradhip ChakrabortyPosted Jul 2, 2009, 8:11 AM
Here I am showing it onmouseover.
You also can refer the following thread:
http://forums.asp.net/p/1118333/1745578.aspx
sara shatsPosted Jul 2, 2009, 8:00 AM
Niradhip ChakrabortyPosted Jul 2, 2009, 7:53 AM