Click here to Skip to main content
16,012,223 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello everybody. I have a problem want people to help.

I create one server control is textBox. i want to create event for them as onchange or onclick. I could create those event or properties for this control by javascript

Thank you very much
Posted

Hi,

You can call event of Server control from Javascript like:

Html or .Aspx
ASP.NET
<asp:textbox id="TextBox1" runat="server" width="308px" xmlns:asp="#unknown"></asp:textbox>


Javascript

HTML
<script language="javascript" type="text/javascript">
        function ChangeHandlerEvent(_this) {
            alert("changed event call from Javascript value is: " + _this.value);
        }
    </script>

Server side or Aspx.cs
C#
protected void Page_Load(object sender, EventArgs e)
       {
           TextBox1.Attributes.Add("onchange", "ChangeHandlerEvent(this)");
       }


Thanks,
Imdadhusen
 
Share this answer
 
Comments
tieudoan208 28-Dec-11 2:38am    
my mind was create server control as control textBox definition those event as TextBox asp.net control. change or click.
Sunasara Imdadhusen 28-Dec-11 7:22am    
ok, but can create custom component and include this code and it will defiantly work.
JavaScript
check this sample code:

var inp = document.createElement('input')
        inp.type = 'text';
        inp.name = 'textfield';
        inp.maxlength = '10';
        inp.id = curr;
        inp.setAttribute('onClick', 'ur function');
 
Share this answer
 
Comments
tieudoan208 28-Dec-11 1:36am    
Thank you so murch but my mind was create server control then packed into dll
file use them as telerick control.
anushripatil 28-Dec-11 1:38am    
Sry i didnt get you clear. If you have the server side control then why not directly use its onclick/on ClientClick event ??? Why javascript for that ??
tieudoan208 28-Dec-11 2:08am    
eg ajaxcontrol toolkit. control updaload have event javascript when upldaod completed

function Upalodconplate(server,arg)
my mind was create server control as control textBox definition those event as TextBox asp.net control. change or click.
 
Share this answer
 
Comments
tieudoan208 28-Dec-11 3:53am    
Somebody help me

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