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 -
protected void Button1_Click(object sender, EventArgs e)
-
{
-
-
if (NewsName.Text == "") { LaukasTuscias.Text = "Irasykit naujienos varda"; } //Please write News Name
-
if (ShortNews.Text == "") { LaukasTuscias.Text = "Irasykit trumpa naujienos versija"; } //Please write Short news
-
if (FullNews.Text == "") { LaukasTuscias.Text = "Irasykit pilna versija"; } //Please write Full news
-
-
if (NewsName.Text == "" || ShortNews.Text == "" || FullNews.Text == "") { dbKlaida.Text = "Klaida, palikot tusciu laukeliu"; } //Error, blank is empty
-
else
-
{
-
SqlConnection conn;
-
SqlCommand comm;
-
-
String connectionString =
-
ConfigurationManager.ConnectionStrings[
-
"Dorknozzle"].ConnectionString;
-
conn = new SqlConnection(connectionString);
-
-
comm = new SqlCommand(
-
"INSERT INTO News (NameNews, ShortNews, FullNews, Author) " +
-
"VALUES (@NameNews, @ShortNews, @FullNews, @Author)", conn);
-
-
comm.Parameters.Add("@Author",
-
System.Data.SqlDbType.NChar, 20);
-
comm.Parameters["@Author"].Value = "Dzimis";
-
-
comm.Parameters.Add("@NameNews",
-
System.Data.SqlDbType.Text);
-
comm.Parameters["@NameNews"].Value = NewsName.Text;
-
-
comm.Parameters.Add("@ShortNews",
-
System.Data.SqlDbType.Text);
-
comm.Parameters["@ShortNews"].Value = ShortNews.Text;
-
-
comm.Parameters.Add("@FullNews",
-
System.Data.SqlDbType.Text);
-
comm.Parameters["@FullNews"].Value = FullNews.Text;
-
-
try
-
{
-
conn.Open();
-
comm.ExecuteNonQuery();
-
}
-
catch (Exception ex)
-
{
-
dbKlaida.Text = "Neprisijunge prie duomenu bazes!<br />" + ex.Message; //Error, don't connect to DB
-
}
-
finally
-
{
-
conn.Close();
-
}
-
dbKlaida.Text = "Duomenys issiusti"; //All Ok
-
NewsName.Text = ""; //Clear TextBox
-
ShortNews.Text = "";
-
FullNews.Text = "";
-
}
-
-
-
}
-
--------------------------------------------------------------------------------
Show News:
-------------------------------------------------------------------------------- -
protected void Page_Load(object sender, EventArgs e)
-
{
-
-
SqlConnection conn;
-
SqlCommand comm;
-
SqlDataReader reader;
-
String connectionString = ConfigurationManager.ConnectionStrings["Dorknozzle"].ConnectionString;
-
-
conn = new SqlConnection(connectionString);
-
comm = new SqlCommand("SELECT Author, ShortNews, ID FROM News", conn);
-
-
try
-
{
-
conn.Open();
-
reader = comm.ExecuteReader();
-
NewsList.DataSource = reader;
-
NewsList.DataBind();
-
-
reader.Close();
-
}
-
catch (Exception ex)
-
{
-
dbKlaida.Text = "Klaida, Neprisijungė prie Duomenų bazės!<br />" + ex.Message; //Error
-
}
-
finally
-
{
-
conn.Close();
-
}
-
}
-
---------------------------- -
<body>
-
<form id="form1" runat="server">
-
<asp:DataList id="NewsList" runat="server">
-
<ItemTemplate>
-
Author: <strong><%#Eval("Author")%></strong><br />
-
Short News: <strong><%#Eval("ShortNews")%></strong><br />
-
<a><center>Read Full News</center></a>
-
</ItemTemplate>
-
<SeparatorTemplate>
-
<hr />
-
</SeparatorTemplate>
-
<SelectedItemStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
-
<AlternatingItemStyle BackColor="White" />
-
<ItemStyle BackColor="#E3EAEB" />
-
<HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
-
</asp:DataList>
-
<asp:Label ID="dbKlaida" runat="server" Text=""></asp:Label>
-
-
</form>
-
</body>
-
-
Thanks
7 1671
Edit:
Can you please clarify your question?
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
Still don't understand my problam?
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.
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...
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:
And create the proper <a> </a> tag to get the link.
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 - <asp:HyperLink ID="FullNewsHyperLink" runat="server" NavigateUrl='<%# Eval("NewsId", Server.HtmlDecode("~/Default.aspx?NewsId={0}")) %>' Text="Full News" />
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Phil Powell |
last post by:
<?php
class FileRemoval {
var $fileNameArray, $isRemoved, $errorMsg = '';
function FileRemoval() {
$this->fileNameArray = array();
$this->isRemoved = 0;
}
|
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...
|
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...
|
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 ...
|
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...
|
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....
|
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...
|
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,...
|
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() {
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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,...
|
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...
|
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,...
|
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...
|
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...
|
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...
| |