Hi friends,
Here I would like to explain a simple technique in asp.net. You can add javascript functionality from serverside to serverside controls. For that, you would require a new web application and choose C# or VB as your code behind.
Add a button control in the newly created appliation. In the form load event add the following code snippet,
Dim str As New StringBuilder
str.Append("alert('hi');")
str.Append("alert(document.getElementById('Button1').value);")
str.Append("document.getElementById('Button1').value='this is a good change happening for a good thing';")
Button1.Attributes.Add("onClick", str.ToString())
In the above code, we have used StringBuilder to append javascript functionality as string and added the functionality using the method
[Control].Attributes.Add("key","value")
Control1.Attributes.Add("onClick", str.ToString()) . Now If you test the application you will be getting the javascript functionality "onClick" event. Hope it helps. |