Monate beim auswahl in der Titel leiste...

M

meequezt

Hallo zusammen,

ich versuch mich seid längeren das alleine hin zu bekommen aber irgendwie gelingt es mir nicht.
Also mein problem ist das ich eine kleine test seite in asp.net vb schreiben will und es ist alles bis jetzt ok.

aspx.jpg


Ich habe MSDE2000 Datenbank abfrage, und die einträge gehen auch.

#aspx.vb code

PHP:
Imports System.Data.SqlClient

Public Class WebForm1
    Inherits System.Web.UI.Page
    Protected WithEvents btnGo As System.Web.UI.WebControls.Button
    Protected WithEvents ddlJahr As System.Web.UI.WebControls.DropDownList
    Protected WithEvents txtVersich As System.Web.UI.WebControls.TextBox
    Protected WithEvents txtAuto As System.Web.UI.WebControls.TextBox
    Protected WithEvents txtKredit As System.Web.UI.WebControls.TextBox
    Protected WithEvents txtCPU As System.Web.UI.WebControls.TextBox
    Protected WithEvents txtBau As System.Web.UI.WebControls.TextBox
    Protected WithEvents txtINet As System.Web.UI.WebControls.TextBox
    Protected WithEvents txtTV As System.Web.UI.WebControls.TextBox
    Protected WithEvents Repeater1 As System.Web.UI.WebControls.Repeater
    Protected WithEvents Form1 As System.Web.UI.HtmlControls.HtmlForm

#Region " Vom Web Form Designer generierter Code "

    'Dieser Aufruf ist für den Web Form-Designer erforderlich.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: Diese Methode ist für den Web Form-Designer erforderlich
        'Verwenden Sie nicht den Code-Editor zur Bearbeitung.
        InitializeComponent()
    End Sub

#End Region


    Public strConn As String = "data source=local;initial catalog=master;persist security info=False;user id=sa; password=; workstation id=local;packet size=4096"

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        LoadData()
    End Sub


    Private Sub btnGo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGo.Click

        Dim strConn As String = "data source=local;initial catalog=master;persist security info=False;user id=sa; password=; workstation id=local;packet size=4096"

        Dim cmd As New SqlCommand("INSERT INTO ausgaben(Auto, Kredit, CPU, Bausparen, Internet, TV) VALUES ('" & txtAuto.Text & "' , '" & txtKredit.Text & "' , '" & txtCPU.Text & "' , '" & txtBau.Text & "' , '" & txtINet.Text & "' , '" & txtTV.Text & "')", New SqlConnection(strConn))

        cmd.Connection.Open()
        cmd.ExecuteNonQuery()
        cmd.Connection.Close()
        LoadData()

    End Sub

    Sub LoadData()

        Dim strConn As String = "data source=local;initial catalog=master;persist security info=False;user id=sa; password=; workstation id=local;packet size=4096"
        Dim strSQL As String = "SELECT * FROM ausgaben"
        Dim cmd As New SqlCommand(strSQL, New SqlConnection(strConn))

        cmd.Connection.Open()
        Repeater1.DataSource = cmd.ExecuteReader
        Repeater1.DataBind()
        cmd.Connection.Close()
        cmd.Connection.Dispose()

    End Sub

End Class

Nur ich will jetzt wenn ich die Monate in der Dropdownlist auswähle das die dann in der Titel leiste erscheinen, gemeinsam mit dem Titel was ich jetzt drin habe:

<title>Monats Ausgaben für Monat</title>

#html code

PHP:
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="ausgaben.aspx.vb" Inherits="winuxnet.WebForm1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
	<HEAD>
		<title>Monats Ausgaben für Monat</title>
		<style type="text/css">BODY { FONT-SIZE: 1px; CLIP: rect(auto 40px auto 40px); FONT-FAMILY: Verdana, Fantasy; BACKGROUND-COLOR: whitesmoke }
		</style>
		<meta content="Microsoft Visual Studio.NET 7.0" name="GENERATOR">
		<meta content="Visual Basic 7.0" name="CODE_LANGUAGE">
		<meta content="JavaScript" name="vs_defaultClientScript">
		<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
	</HEAD>
	<body MS_POSITIONING="GridLayout">
		<form id="Form1" method="post" runat="server">
			<div align="center">
				<h1 style="FONT-SIZE: xx-small; FONT-FAMILY: Verdana,Fantasy; BACKGROUND-COLOR: whitesmoke; TEXT-ALIGN: center" runat="server">Einträge 
					für die Monats ausgabe</h1>
				<TABLE id="Table1" style="WIDTH: 296px; HEIGHT: 90px" borderColor="#cccc99" cellSpacing="1" cellPadding="0" width="296" align="center" bgColor="dimgray" border="0">
					<tr align="left">
						<td style="HEIGHT: 40px" vAlign="center" bgColor="gray">
							<P><FONT color="#ffffff" size="1"><STRONG><U>Type:</U></STRONG></FONT></P>
						</td>
						<td style="HEIGHT: 40px" bgColor="gray">
							<P><FONT color="#ffffff" size="1"><STRONG><U>Eintrag im Datenbank:</U></STRONG></FONT></P>
						</td>
					</tr>
					<TR bgColor="#cccccc">
						<TD>
							<DIV style="DISPLAY: inline; WIDTH: 70px; HEIGHT: 15px" ms_positioning="FlowLayout"><FONT face="Verdana" size="1">Monat:</FONT></DIV>
						</TD>
						<TD><asp:dropdownlist id="ddlJahr" runat="server" Font-Size="XX-Small">
								<asp:ListItem Value="Jänner">Jänner</asp:ListItem>
								<asp:ListItem Value="Februar">Februar</asp:ListItem>
								<asp:ListItem Value="März">März</asp:ListItem>
								<asp:ListItem Value="April">April</asp:ListItem>
								<asp:ListItem Value="Mai">Mai</asp:ListItem>
								<asp:ListItem Value="Juni">Juni</asp:ListItem>
								<asp:ListItem Value="Juli">Juli</asp:ListItem>
								<asp:ListItem Value="August">August</asp:ListItem>
								<asp:ListItem Value="Septebmer">Septebmer</asp:ListItem>
								<asp:ListItem Value="Oktober">Oktober</asp:ListItem>
								<asp:ListItem Value="November">November</asp:ListItem>
								<asp:ListItem Value="Dezember">Dezember</asp:ListItem>
							</asp:dropdownlist></TD>
					</TR>
					<TR bgColor="#cccccc">
						<TD>
							<DIV style="DISPLAY: inline; WIDTH: 70px; HEIGHT: 15px" ms_positioning="FlowLayout"><FONT face="Verdana" size="1">Versicherung:</FONT></DIV>
						</TD>
						<TD><asp:textbox id="txtVersich" runat="server" Font-Size="XX-Small" Height="16px" Width="100px"></asp:textbox></TD>
					</TR>
					<TR bgColor="#cccccc">
						<TD>
							<DIV style="DISPLAY: inline; WIDTH: 102px; HEIGHT: 15px" ms_positioning="FlowLayout">
								<P><FONT face="Verdana" size="1">Auto ausgaben</FONT><FONT face="Verdana" size="1">:</FONT></P>
							</DIV>
						</TD>
						&lt;
						<TD><asp:textbox id="txtAuto" runat="server" Font-Size="XX-Small" Height="16px" Width="100px"></asp:textbox></TD>
					</TR>
					<tr bgColor="#cccccc">
						<td>
							<DIV style="DISPLAY: inline; WIDTH: 70px; HEIGHT: 15px" ms_positioning="FlowLayout"><FONT size="1">Kredite:</FONT></DIV>
						</td>
						<td><asp:textbox id="txtKredit" runat="server" Font-Size="XX-Small" Height="16px" Width="100px"></asp:textbox></td>
					</tr>
					<tr bgColor="#cccccc">
						<td>
							<DIV style="DISPLAY: inline; WIDTH: 70px; HEIGHT: 15px" ms_positioning="FlowLayout"><FONT size="1">Ausgaben&nbsp;CPU:</FONT></DIV>
						</td>
						<td><asp:textbox id="txtCPU" runat="server" Font-Size="XX-Small" Height="16px" Width="100px"></asp:textbox></td>
					</tr>
					<tr bgColor="#cccccc">
						<td>
							<DIV style="DISPLAY: inline; WIDTH: 70px; HEIGHT: 15px" ms_positioning="FlowLayout"><FONT size="1">Bausparen:</FONT></DIV>
						</td>
						<td><asp:textbox id="txtBau" runat="server" Font-Size="XX-Small" Height="16px" Width="100px"></asp:textbox></td>
					</tr>
					<tr bgColor="#cccccc">
						<td>
							<DIV style="DISPLAY: inline; WIDTH: 122px; HEIGHT: 15px" ms_positioning="FlowLayout"><FONT size="1">Internet 
									Kosten:</FONT></DIV>
						</td>
						<td><asp:textbox id="txtINet" runat="server" Font-Size="XX-Small" Height="16px" Width="100px"></asp:textbox></td>
					</tr>
					<tr bgColor="#cccccc">
						<td>
							<DIV style="DISPLAY: inline; WIDTH: 107px; HEIGHT: 18px" ms_positioning="FlowLayout"><FONT size="1">TV&nbsp;Kosten:</FONT></DIV>
						</td>
						<td><asp:textbox id="txtTV" runat="server" Font-Size="XX-Small" Height="16px" Width="100px"></asp:textbox></td>
					</tr>
					<tr bgColor="#cccccc">
						<td vAlign="top">
							<DIV style="DISPLAY: inline; WIDTH: 70px; HEIGHT: 15px" align="left" ms_positioning="FlowLayout"><FONT size="1">Kommetere:</FONT></DIV>
						</td>
						<td vAlign="top"><TEXTAREA id="txtComm" style="WIDTH: 434px; HEIGHT: 152px" rows="9" cols="51">							</TEXTAREA><BR>
						</td>
					</tr>
					<tr bgColor="#cccccc">
						<td></td>
						<td><BR>
							<asp:button id="btnGo" runat="server" Font-Size="XX-Small" Width="100px" Text="Weiter >"></asp:button></td>
					</tr>
				</TABLE>
				<asp:Repeater id="Repeater1" runat="server"></asp:Repeater></div>
		</form>
	</body>
</HTML>
 
Hallo meequezt,


also als erstes würde ich in meinem Kopf ein Label einfügen, in dem der Monatsname stehen soll, also ungefähr so:

PHP:
<h1 style="FONT-SIZE: xx-small; FONT-FAMILY: Verdana,Fantasy; BACKGROUND-COLOR: whitesmoke; TEXT-ALIGN: center" runat="server">Eintrag für den Monat <asp:Label id="monatsname" runat="server"></asp:Label></h1>

Dann fügst du zu deiner DropDownListe mit den Monaten noch das OnChange-Ereignis zu:

PHP:
<asp:dropdownlist
    id="ddlJahr"
    OnSelectedIndexChanged="auswahl_monat"
    AutoPostBack="true"
    runat="server"
    Font-Size="XX-Small"> 
                                <asp:ListItem Value="Jänner">Jänner</asp:ListItem> 
                                <asp:ListItem Value="Februar">Februar</asp:ListItem> 
                                <asp:ListItem Value="März">März</asp:ListItem> 
                                <asp:ListItem Value="April">April</asp:ListItem> 
                                <asp:ListItem Value="Mai">Mai</asp:ListItem> 
                                <asp:ListItem Value="Juni">Juni</asp:ListItem> 
                                <asp:ListItem Value="Juli">Juli</asp:ListItem> 
                                <asp:ListItem Value="August">August</asp:ListItem> 
                                <asp:ListItem Value="Septebmer">Septebmer</asp:ListItem> 
                                <asp:ListItem Value="Oktober">Oktober</asp:ListItem> 
                                <asp:ListItem Value="November">November</asp:ListItem> 
                                <asp:ListItem Value="Dezember">Dezember</asp:ListItem> 
                            </asp:dropdownlist>


Dann fügst du in der Page_Load folgenden Code ein (bin C#-Programmierer und hoffe das der Code in VB so richtig ist...)

PHP:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        LoadData()

        if (!IsPageLoad)
        {
                monatsname.Text = ddlJahr.SelectedItem.Text
        }
    End Sub

Dann brauchst du noch die Funktion, die aufgerufen wird, wenn sich der Inhalt der DropDownListe ändert:

PHP:
public void auswahl_monat(Object sender, EventArgs e)
{
        monatsname.Text = ddlJahr.SelectedItem.Text
}


na dann, viel Spaß beim ausprobieren,


ciao Anke
 

Neue Beiträge

Zurück