adding news problem

Discussion in 'C#' started by laado, Dec 29, 2009.

  1. #1
    i have following code for adding news. when i press add news button it automatically add news with title "news title" and "new news text". i want that when i press add button it open a form to add add news.
    thee code is following

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    
    <html>
    <head>
    	<title>Add News</title>
    </head>
    
    <!-- #INCLUDE FILE="settings.asp" -->
    <%
    id = request("id")
    response.write ID
    if not isnumeric(id) then
    	response.write errmessage
    	response.end
    end if
    
    addlatestnews = request("addlatestnews")
    delnews = request("delnews")
    
    Set dConn = Server.CreateObject("ADODB.Connection")
    dConn.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & database_path
    
    if addlatestnews = 1 then
    insertdate = FormatDateTime(Now(), vbShortDate)
    	mySQL = "INSERT INTO latestNews(newstitle, newsbody, newsdate, active) VALUES ('New News Title', 'New News Text', #" & insertdate & "#, 1);"
    	dConn.execute(mySQL)
    	redirect = "news-admin.asp"
    end if
    
    if delnews = 1 then
    	mySQL = "DELETE FROM latestnews where ID = " & id & ";"
    	dConn.execute(mySQL)
    	redirect = "news-admin.asp"
    end if
    
    dconn.close
    %>
    
    <script language="javascript">
    <!-- 
    location.replace("<%=redirect%>");
    -->
    </script>
    </html>
    Code (markup):
    please help me. wht change in this code so that when i press add button the form of add news will display.i need urgent help.
     
    laado, Dec 29, 2009 IP
  2. laado

    laado Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    simply form. i just want when i click add news button a form open in which i write news. then save it. when i save it will save in database.
     
    laado, Dec 29, 2009 IP
  3. rkstech

    rkstech Active Member

    Messages:
    195
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    73
    #3
    HI

    What is this for
    <script language="javascript">
    <!--
    location.replace("<%=redirect%>");
    -->
    </script>
     
    rkstech, Dec 30, 2009 IP
  4. hemant.yadav

    hemant.yadav Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    On button click event write the following code to redirect the page.
    server side.

    Response.Redirect("yourpage.aspx",false);
     
    hemant.yadav, Jan 3, 2010 IP
  5. bertasoft

    bertasoft Peon

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I think he is talking about classic asp, so there isn't a server side click event.
     
    bertasoft, Jan 8, 2010 IP