Dim tblMy As New DataTable()
        Dim rw1, rw2, rw3 As DataRow
        Dim c1 As New DataColumn("ID")
        Dim c2 As New DataColumn("Team")

        tblMy.Columns.Add(c1)
        tblMy.Columns.Add(c2)

        rw1 = tblMy.NewRow()
        rw1.Item("ID") = 1
        rw1.Item("Team") = "Team 1"
        tblMy.Rows.Add(rw1)

        rw2 = tblMy.NewRow()
        rw2.Item("ID") = 2
        rw2.Item("Team") = "Team 2"
        tblMy.Rows.Add(rw2)

        rw3 = tblMy.NewRow()
        rw3.Item("ID") = 3
        rw3.Item("Team") = "Team 3"
        tblMy.Rows.Add(rw3)
      

 An easy ways to do this is to call the __doPostBack() function of the javascript. An example is as follows:

 <input type="button" id="Button2" value="Button 2 Click" onclick="DoPostBack()" />


<script language="javascript" type="text/javascript">

function DoPostBack()
{
  //Any javascript statements....

__doPostBack('Button2','My Argument');
}

</script>
 

However in  Visual Studio 2005, the server and the client code can be directly run from the button attributes only.

OnClick property: For server side scripts

OnClientClick: For client side scripts

E.g. 

<asp:Button ID="btnClickMe" runat="server" Text="Click Me" OnClick ="btnClickMe_Click"  OnClientClick="DoPostBack();" />


 

                // ***** First Method *****//
                var rdolist = document.getElementsByName("rdolist");
                
                if (rdolist[1].checked)
                    txtMessage.value = "First";
                if (rdolist[2].checked)
                    txtMessage.value = "Second";
                if (rdolist[3].checked)
                    txtMessage.value = "Third";
                
                
 

               // ***** Second Method *****//
                var rdolist_0 = document.getElementById("rdolist_0");
                var rdolist_1 = document.getElementById("rdolist_1");
                var rdolist_2 = document.getElementById("rdolist_2");
                if (rdolist_0.checked)
                    txtMessage.value = "First";
                if (rdolist_1.checked)
                    txtMessage.value = "Second";
                if (rdolist_2.checked)
                    txtMessage.value = "Third";

 Hello Everybody,

                               I have been blogging long on my domain www.azamatali.com  and have been thinking of starting a technical blog. 

          As a regular visitor of asp.net website, I came through the offer by Joe to have a blog @ asp.net. 

          Thanks to Joe for providing me the opportunity to have this blog and I would be using this platform to post about the things I know and would like to share with all of you.

Here I come :)

More Posts