Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <%@ Page Language="VB" %>
- <%@ Import Namespace="System.Data.SqlClient" %>
- <%@ Import Namespace="System.Data" %>
- <%@ Import Namespace="System.Net" %>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <script type="text/javascript" language="javascript">
- function YouSure()
- {
- return confirm("This will add this article onto the News page (www.site.co.uk/news) immediately\nAre you sure you want to do this?","title")
- }
- </script>
- <script runat="server">
- Protected Sub Submit_Click(ByVal sender As Object, ByVal e As System.EventArgs)
- 'If MsgBox("This will add this article onto the News page (www.site.co.uk/news) immediately" & _
- ' vbCrLf & "Are you sure you want to do this?", MsgBoxStyle.YesNo + MsgBoxStyle.Question + MsgBoxStyle.DefaultButton2, "Submit News Article?") = MsgBoxResult.Yes Then
- Call foo()
- 'Else
- ' 'Cancelled
- ' MsgBox("This News Article will not be added to the system", MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "Operation Cancelled")
- 'End If
- End Sub
- Sub foo()
- Dim strTitle as String=contitle.Text
- dim strContent as String=concontent.Text
- dim dtDate as Date=format(Today(), "yyyy-MM-dd")
- Dim strConn As String = "Data Source=DEDICAT-NJSHC7G\SQLEXPRESS;Initial Catalog=listrweb;UID=user;PWD=pass"
- Dim MyConn As New SqlConnection(strConn)
- Dim MySQL As String = "INSERT INTO tblNews (Page, News, DateItem, Active) values ('" & _
- Replace(strTitle, "'", "") & "', '" & Replace(strContent, "'", "") & "', '" & format(Today(), "yyyy-MM-dd") & "', 'Yes')"
- Dim Cmd As New SqlCommand(MySQL, MyConn)
- MyConn.Open()
- Try
- Cmd.ExecuteNonQuery()
- Catch ex As Exception
- Server.Transfer("news_problem.aspx")
- Exit Sub
- End Try
- MyConn.Close()
- Server.Transfer("news_worked.aspx")
- End Sub
- Private Sub getErrorMessage(ByVal theReasonForTheError As String)
- MsgBox("Your error message is: " & vbNewLine & theReasonForTheError, MsgBoxStyle.Critical)
- End Sub
- </script>
- <html xmlns="http://www.w3.org/1999/xhtml" >
- <head>
- <title>List Recruitment :: Add News Page</title>
- <link rel="stylesheet" type="text/css" title="BP Colour Scheme" href="css/menu.css" />
- <link rel="stylesheet" type="text/css" title="BP Colour Scheme" href="css/table.css" />
- <script language="VB" runat="server" type="text/VB">
- Sub Page_Load(ByVal Source As Object, ByVal E As EventArgs)
- 'Check if there is an active session
- If Len(Session.Item("fname")) = 0 Then
- 'No active session - get the user to log in first
- Response.Redirect("login.aspx")
- 'Else
- 'There is an active session - ie user has logged in.
- 'label2.Text = "<strong>Hello " & Session("fname") & ", welcome to the BP Ops Support Online Job Tracking System.<br />Click Active Tasks to get started!</strong><br /><br /><strong>Please note:</strong> If you close the browser window, or leave the screen unattended for 20 minutes, you will need to log back in."
- End If
- End Sub
- </script>
- </head>
- <body style="background-image:none; font-family: Arial; position: static; text-align: left;">
- <table border="0" style="width: 100%">
- <tr>
- <td rowspan="2" style="width: 155px">
- </td>
- <td align="right" colspan="2" rowspan="2">
- <a href="http://www.site.co.uk" id="Back to main website" target="_blank"><img alt="Back to main site Website" src="img/list_rec.jpg" border="0"/></a></td>
- </tr>
- </table>
- <div class="menutabs">
- <ul>
- <li><a href="#">Job Listing Administration</a></li>
- </ul>
- </div>
- <span class="BPHeading"><br />Add News Article<br /></span>
- <form id="form1" runat="server">
- <div class="table">
- <ul>
- <li class="even"><asp:Label ID="newsTitle" runat="server" Font-Bold="True" Text="Article Title"></asp:Label></li>
- <li class="odd"><asp:Label ID="newsContent" runat="server" Font-Bold="True" Text="Article Content"></asp:Label></li>
- </ul>
- <ul>
- <li class="even"><asp:TextBox ID="conTitle" runat="server" Width="500px"></asp:TextBox></li>
- <li class="odd"><asp:TextBox ID="conContent" runat="server" Height="192px" Width="500px" TextMode="MultiLine"></asp:TextBox></li>
- </ul>
- </div>
- <div>
- <asp:Button ID="Submit" runat="server" OnClientClick="return YouSure();" OnClick="Submit_Click" Text="Submit" Width="81px" />
- </div>
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement