.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> Javascript >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

How Javascript can be helpful to execute code between two web pages

Posted By:Mahesh       Posted Date: March 17, 2011    Points: 40    Category: Javascript    URL: http://www.dotnetspark.com  

How Javascript can be helpful to execute code between two web pages
 

Hi Friends this post will show how we can execute server side code from the previous page by executing events from other page, here is the code,

First page code

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>





Untitled Page




LinkButton



VB code

Imports System.Data

Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
Dim dt As New DataTable
dt.Columns.Add("t1")
dt.Columns.Add("t2")
dt.Columns.Add("t3")

Dim dr As DataRow = dt.NewRow
dr.Item("t1") = "1"
dr.Item("t2") = "2"
dr.Item("t3") = "3"

dt.Rows.Add(dr)

dr = dt.NewRow
dr.Item("t1") = "1"
dr.Item("t2") = "2"
dr.Item("t3") = "3"

dt.Rows.Add(dr)


GridView1.DataSource = dt
GridView1.DataBind()
LinkButton1.Attributes.Add("onclick", "window.open('Default2.aspx')")
End If

End Sub

Private Sub PopulateData()
Dim dt As New DataTable
dt.Columns.Add("t1")
dt.Columns.Add("t2")
dt.Columns.Add("t3")

Dim dr As DataRow = dt.NewRow
dr.Item("t1") = "1"
dr.Item("t2") = "2"
dr.Item("t3") = "3"

dt.Rows.Add(dr)

dr = dt.NewRow
dr.Item("t1") = "4"
dr.Item("t2") = "5"
dr.Item("t3") = "6"

dt.Rows.Add(dr)


GridView1.DataSource = dt
GridView1.DataBind()
End Sub

Protected Sub btnProcess_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnProcess.Click
PopulateData()
End Sub
End Class

Second page

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default2.aspx.vb" Inherits="Default2" %>





Untitled Page



VB code Partial Class Default2 Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Button1.Attributes.Add("onclick", "AssignValue()") End Sub End Class


     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend