473,396 Members | 2,010 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Write news script

30
Hi, I write News Script:
Write news skript, but how maket that - Whent I push "Read Full News" show full news? Some like that: http://blogs.msdn.com/


Sorry, for bad English


My script
Expand|Select|Wrap|Line Numbers
  1.  protected void Button1_Click(object sender, EventArgs e)
  2.     {
  3.  
  4.         if (NewsName.Text == "") { LaukasTuscias.Text = "Irasykit naujienos varda"; }  //Please write News Name
  5.         if (ShortNews.Text == "") { LaukasTuscias.Text = "Irasykit trumpa naujienos versija"; } //Please write Short news 
  6.         if (FullNews.Text == "") { LaukasTuscias.Text = "Irasykit pilna versija"; }  //Please write Full news
  7.  
  8.         if (NewsName.Text == "" || ShortNews.Text == "" || FullNews.Text == "") { dbKlaida.Text = "Klaida, palikot tusciu laukeliu"; } //Error, blank is empty
  9.         else
  10.         {
  11.             SqlConnection conn;
  12.             SqlCommand comm;
  13.  
  14.             String connectionString =
  15.             ConfigurationManager.ConnectionStrings[
  16.             "Dorknozzle"].ConnectionString;
  17.             conn = new SqlConnection(connectionString);
  18.  
  19.             comm = new SqlCommand(
  20.             "INSERT INTO News (NameNews, ShortNews, FullNews, Author) " +
  21.             "VALUES (@NameNews, @ShortNews, @FullNews, @Author)", conn);
  22.  
  23.             comm.Parameters.Add("@Author",
  24.             System.Data.SqlDbType.NChar, 20);
  25.             comm.Parameters["@Author"].Value = "Dzimis";
  26.  
  27.             comm.Parameters.Add("@NameNews",
  28.             System.Data.SqlDbType.Text);
  29.             comm.Parameters["@NameNews"].Value = NewsName.Text;
  30.  
  31.             comm.Parameters.Add("@ShortNews",
  32.             System.Data.SqlDbType.Text);
  33.             comm.Parameters["@ShortNews"].Value = ShortNews.Text;
  34.  
  35.             comm.Parameters.Add("@FullNews",
  36.             System.Data.SqlDbType.Text);
  37.             comm.Parameters["@FullNews"].Value = FullNews.Text;
  38.  
  39.             try
  40.             {
  41.                 conn.Open();
  42.                 comm.ExecuteNonQuery();
  43.             }
  44.             catch (Exception ex)
  45.             {
  46.                 dbKlaida.Text = "Neprisijunge prie duomenu bazes!<br />" + ex.Message; //Error, don't connect to DB
  47.             }
  48.             finally
  49.             {
  50.                 conn.Close();
  51.             }
  52.             dbKlaida.Text = "Duomenys issiusti";  //All Ok
  53.             NewsName.Text = ""; //Clear TextBox
  54.             ShortNews.Text = "";
  55.             FullNews.Text = "";
  56.         }
  57.  
  58.  
  59.     }
  60.  
--------------------------------------------------------------------------------
Show News:
--------------------------------------------------------------------------------
Expand|Select|Wrap|Line Numbers
  1.  protected void Page_Load(object sender, EventArgs e)
  2.     {
  3.  
  4.         SqlConnection conn;
  5.         SqlCommand comm;
  6.         SqlDataReader reader;
  7.         String connectionString = ConfigurationManager.ConnectionStrings["Dorknozzle"].ConnectionString;
  8.  
  9.         conn = new SqlConnection(connectionString);
  10.         comm = new SqlCommand("SELECT Author, ShortNews, ID FROM News", conn);
  11.  
  12.         try
  13.         {
  14.             conn.Open();
  15.             reader = comm.ExecuteReader();
  16.             NewsList.DataSource = reader;
  17.             NewsList.DataBind();
  18.  
  19.             reader.Close();
  20.         }
  21.         catch (Exception ex)
  22.         {
  23.             dbKlaida.Text = "Klaida, Neprisijungė prie Duomenų bazės!<br />" + ex.Message; //Error
  24.         }
  25.         finally
  26.         {
  27.             conn.Close();
  28.         } 
  29.     }
  30.  
----------------------------
Expand|Select|Wrap|Line Numbers
  1. <body>
  2.     <form id="form1" runat="server">
  3.           <asp:DataList id="NewsList" runat="server">
  4. <ItemTemplate>
  5. Author: <strong><%#Eval("Author")%></strong><br />
  6. Short News: <strong><%#Eval("ShortNews")%></strong><br />
  7. <a><center>Read Full News</center></a>
  8. </ItemTemplate>
  9. <SeparatorTemplate>
  10. <hr />
  11. </SeparatorTemplate>
  12. <SelectedItemStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
  13. <AlternatingItemStyle BackColor="White" />
  14. <ItemStyle BackColor="#E3EAEB" />
  15. <HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
  16. </asp:DataList>
  17.      <asp:Label ID="dbKlaida" runat="server" Text=""></asp:Label>
  18.  
  19.     </form>
  20. </body>
  21.  
  22.  
Thanks
Aug 13 '08 #1
7 1671
Curtis Rutland
3,256 Expert 2GB
Edit:
Can you please clarify your question?
Aug 13 '08 #2
Smurfas
30
Edit:
Can you please clarify your question?
Sorry, I bad speak English...
I need sample News scriptas(Write news in my page)

I have pictures, I hope now youn understand:




http://smurfas.puslapiai.lt/newsScript.JPG
Aug 13 '08 #3
Smurfas
30
Still don't understand my problam?
Aug 14 '08 #4
Curtis Rutland
3,256 Expert 2GB
Hmm, I think I understand the question, but it is a pretty general one.

What you are doing is basically a "blog." Try searching for some sample ASP.NET Blogs to see if you find anything.
Aug 14 '08 #5
RedSon
5,000 Expert 4TB
No I think the question is, how can he render the html such that the "read full news" link is an actual URL to the page that has the full news story...
Aug 14 '08 #6
RedSon
5,000 Expert 4TB
No I think the question is, how can he render the html such that the "read full news" link is an actual URL to the page that has the full news story...
I would imagine you can do something similar to this item:
Expand|Select|Wrap|Line Numbers
  1. <%#Eval("ShortNews")%>
  2.  
And create the proper <a> </a> tag to get the link.
Aug 14 '08 #7
Smurfas
30
Hmm, I think I understand the question, but it is a pretty general one.

What you are doing is basically a "blog." Try searching for some sample ASP.NET Blogs to see if you find anything.

Yes, I need simple Blog sample or guest book without xml.

I some have, what i need, but i need full example
Expand|Select|Wrap|Line Numbers
  1. <asp:HyperLink ID="FullNewsHyperLink" runat="server" NavigateUrl='<%# Eval("NewsId", Server.HtmlDecode("~/Default.aspx?NewsId={0}")) %>' Text="Full News" /> 
Aug 14 '08 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Phil Powell | last post by:
<?php class FileRemoval { var $fileNameArray, $isRemoved, $errorMsg = ''; function FileRemoval() { $this->fileNameArray = array(); $this->isRemoved = 0; }
1
by: Bob Murdoch | last post by:
I have a situation where I call a COM object from ASP that is supposed to create a file. On occasion, especially during development, the output of the COM function is an error string rather than...
6
by: Mike Daniel | last post by:
I am attempting to use document.write(pageVar) that displays a new html page within a pop-up window and the popup is failing. Also note that pageVar is a complete HTML page containing other java...
3
by: Ike | last post by:
Can anyone discern why the following code writes the document.write() lines literally? That is, a line like document.write('<CENTER>') should write <CENTER> but instead writes the entire ...
4
by: Razzbar | last post by:
I need to be able to conditionally load a remote script, using the "<script src=..." syntax. Or some other way. I've seen people writing about using the document.write method, but it's not working...
8
by: Ben | last post by:
Hi all, Just wondering how to write (using document.write) to a table cell. I have table with 3 rows and 3 colums. I want to write from within the Javascript to say third column of a first row....
14
by: Eli | last post by:
I've got a script that I'm trying to debug which uses document.write() to place HTML within a page. In both IE6 and Firefox when I view source, I see only the script itself and not any HTML as...
4
by: Prowler | last post by:
In the application we are currently building, we need to write positioning code on-the-fly, based upon the screen offset of the element in the AS/400 application which drives the Web app. The 400,...
2
by: bissatch | last post by:
Hi, I am trying to use JavaScript to write a table column on a web page. The code is as follows: <html> <head> <script> function displaycount() {
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.