Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
how to restrict postback on entire page in asp.net
AND
how to get Datamember and ValueMembet value of selected item in combobox through JavaScript in asp.net
Posted

Guess what, I found both answers with ggogle...


Ramesh Reddy11111 wrote:
how
to restrict postback on entire page in asp.ne


Remove the runat="server" attribute from the control

You can also add an onclick attribute to the control and return true i.e.
YourButton.Attributes.Add("onclick", "<script>return true</script>");



Ramesh Reddy11111 wrote:
how to get Datamember and ValueMembet value of selected item in combobox through JavaScript


<asp:TextBox ID="txtDate" runat="server"></asp:TextBox>
<img src="images\cal.gif" 
onclick="openCalendar(<% = txtDate.ClientID %>, 150, -150);return false;" />


A little more proper way would be:

<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="images/cal.gif" />


protected void Page_Load(object sender, EventArgs e)
{
ImageButton1.OnClientClick = "openCalendar(" + TextBox1.ClientID + ", " + X.ToString() + ", " + Y.ToString() + ");return false;";
}
 
Share this answer
 
to get the value in the combobox you should use the following code in the page load event.........

if(!IsPostback)
{
//write here code that execute on page load
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900