combining funtionality from two pages

  • Thread starter Thread starter slinky
  • Start date Start date
S

slinky

Thanks for any help folks:

I have two .aspx pages that are workling well: one is for entering
entries in a blog and another for viewing those entries. What I want
to do is combine the two into one so I have a textbox and submit
button at the top and the blog entries below. Any ideas?


Here is my entry page:


<%@ import Namespace="System.Data" %>
<script runat="server">
Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
Using ds As New DataSet()
ds.ReadXml(Server.MapPath("blog.xml"))
txtNewEvent.DataBind()
txtDate.DataBind()
End Using
End If
End Sub
Private Sub btnSubmit_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnSubmit.Click
Using ds As New DataSet()
ds.ReadXml(Server.MapPath("blog.xml"))
Dim dr As DataRow = ds.Tables(0).NewRow()
dr("entry") = txtNewEvent.Text
dr("name") = txtDate.Text
ds.Tables(0).Rows.Add(dr)
ds.WriteXml(Server.MapPath("blog.xml"))
Response.Redirect("http://site.com/Default.aspx")
End Using
End Sub


Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs)
Response.Redirect("http://site.com/Default.aspx")
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Blog Entry</title>
<style type="text/css">
#Form1
{
height: 508px;
width: 727px;
}
</style>
</head>


<body background="vignette.gif" runat="server">
<a href="javascript:my_win()"></a> <form id="Form1" method="post"
runat="server">

<b>
<a href="/demos/books.xml"></a>
<asp:Label ID="Label2" runat="server" BackColor="#00C0C0" Font-
Bold="True" Font-Size="Large"
Text="Enter your comments into our blog:" Width="375px"
BorderStyle="Outset"></asp:Label>
<asp:TextBox ID="txtNewEvent" runat="server" Width="451px"
Height="212px"
style="padding-right: 5%; padding-left: 5%; padding-bottom:
5%; margin: 5%; padding-top: 5%"
TextMode="MultiLine"></asp:TextBox>

<asp:Button ID="btnSubmit" runat="server" Text="Submit"
OnClick="btnSubmit_Click" /></b><br />
<asp:Label ID="Label1" runat="server" BackColor="#00C0C0"
Font-Bold="True" Text="Your Name" BorderStyle="Outset"></asp:Label>
<asp:TextBox ID="txtDate" runat="server" Width="266px"></
asp:TextBox>


<p>
<b>
<asp:Button ID="Button1" runat="server" BackColor="Aqua"
Style="z-index: 107; left: 750px;
position: absolute; top: 488px; font-weight: 700; width:
168px;"
Text="Home" onclick="Button1_Click" />
</b></p>
<p>


</p>
</form>
</body>
</html>


Here is my viewing page:


<%@ import Namespace="System.Data" %>
<script runat="server">
Private Function MakeDataView() as DataView
Dim myDataSet As New DataSet()
myDataSet.ReadXml(Server.MapPath("blog.xml"))
Dim view As DataView = New DataView(myDataSet.Tables(0))
view.AllowDelete = False
view.AllowEdit = False
view.AllowNew = False
view.Sort = "name ASC"
Return view
End Function


Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
Dim view as DataView = MakeDataView()
dgBooksPretty.DataSource = view
dgBooksPretty.AllowSorting = True
dgBooksPretty.DataBind()
End Sub
</script>


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


<head id="Head1" runat="server">
<title>Our Blog</title>
</head>
<body borderwidth="20px" background="vignette.gif">
<div align="left"
style="border-style: inset; border-color: white;
overflow: auto; font-size: medium; width: 84%;
font-family: 'Times New Roman'; height: 599px;
color: black; left: 79px; position: absolute;
top: 11%; background-color: #ccffff; padding-right:
10px; float: none; margin-left: 20px;
clip: rect(auto auto auto auto); text-indent: 5%;
text-align: left; padding-left: 10px;">
<div style="text-indent: 20px">
<asp:datagrid id="dgBooks"
runat="server"
Visible="False"
Height="1px"
Width="1px" />
<asp:datagrid id="dgBooksPretty"
runat="server"
AutoGenerateColumns="False"
Font-Name="Verdana"
Font-Size="Small"


HorizontalAlign="Center"
ItemStyle-BackColor="#C0FFC0"
AlternatingItemStyle-BackColor="White"
Width="911px"
Height="128px"
AllowSorting="True"
BorderColor="PeachPuff"
BorderStyle="Outset"
BorderWidth="10px" CellSpacing="2">
<HeaderStyle BackColor="DarkGreen"
HorizontalAlign="Center"
ForeColor="White"
Font-Bold="True" />
<Columns>
<asp:BoundColumn HeaderText="Blog Entry" DataField="entry" />
<asp:BoundColumn HeaderText="Name" DataField="name" />
</Columns>
<AlternatingItemStyle BackColor="White" />
<ItemStyle BackColor="#C0FFC0" />
</asp:datagrid>
<p align="center">
</p>
</body>
</html>
 
Back
Top