Jump to content

Displaying a block of content


ZeroShade

Recommended Posts

I need to display a block of content only when that page has content... this is done using a database. So if the user clicks on a link that pulls information from the database then the close updates and expand updates work... but now I need something to say "hey... there isn't any content here... we can't say close and expand updates if their are none". What I have already is below.

<script type="text/javascript">		function HideComments()		{			var comments = document.getElementById('comments');			var mainText = document.getElementById ('text');						if(comments.style.display=='none')			{				comments.style.display='block';				text.innerHTML = '<a href="java script:HideComments();">Close Updates</a>';			}			else			{				comments.style.display='none';				text.innerHTML = '<a href="java script:HideComments();">Expand Updates</a>';			}		}	</script>

Link to comment
Share on other sites

I looked into how to do what you are saying but the fact is... I don't know enough javascript to do this. I understand that Javascript cannot access the database directly and that I have to use AJAX to do fetch the information but thats where I'm stuck again... I don't know AJAX very well either. If there is a way to do it in asp.net then I can attempt that. I tried using an example on w3schools as well but I found I had to change a lot of code around and pull up keywords I don't know or what they really do. Would somebody be able to give me a simple example taking how many rows in the table and saying there isn't enough and implement it into what I already have for javascript?

Link to comment
Share on other sites

So your saying it is possible to call procedures and such from a database using just javascript?
I think what he meant was that using AJAX incorrectly could expose details that you might not want exposed. With AJAX, you send a request to the server and the server-side code processes that request and returns a response. The access to the database would need to be done server-side, javascript is just used to ask the server for the data. As long as you code the server-side stuff correctly, AJAX is no more dangerous than the address bar on the browser.That being said, with .NET, you can do something like this-.aspx
<asp:Panel id="CommentNavigationPanel" runat="server" Visible="false">  <a href="java script:HideComments();">Expand Updates</a></asp>

.aspx.cs

protected void Page_Load(object sender, EventArgs e){	// Get the data however you normally get it and then, for	// the sake of this example, put it in a DataTable.	// Then, once you have the data, check to see if there are	// any rows and display the comment navigation panel if it	// needs to be displayed	if(DataTable.Rows.Count > 0)	{		CommentNavigationPanel.Visible = true;	}}

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...