Posts
337
Comments
125
Trackbacks
5
JavaScript-Funktion von code behind aus aufrufen

Hier ein weiteres Beispiel dafür, wie man von code behind aus eine Javascript-Funktion aufrufen kann

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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head id="Head1" runat="server">

<title></title>

</head>

<body>

<script language="javascript">

function TestCodebehind() {

        alert("JavaScript-Aufruf von codebehind aus hat geklappt");

    }

</script>

<form id="form1" runat="server">

<div>

<asp:Button ID="Button1" runat="server" Text="Button" />

<asp:Label ID="Javascript" runat="server" Text=""></asp:Label>

</div>

</form>

</body>

</html>

Die dazugehörige code behind Datei:

Partial Class test

Inherits System.Web.UI.Page

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

        Javascript.Text = "<script>TestCodebehind()</" + "script>"

    End Sub

End Class

 

posted on Saturday, March 28, 2009 11:13 AM Print
Comments
No comments posted yet.

Post Comment

Title *
Name *
Email
Url
Comment *  
Please add 5 and 4 and type the answer here: