Jump to content

jesh

Members
  • Posts

    2,293
  • Joined

  • Last visited

Posts posted by jesh

  1. I don't know if you're using IE and .innerHTML or not, but this seems to work for me in both Firefox and IE:

    // doesn't work in IE://document.getElementById("mytextarea").innerHTML = "title:\nparagraph:";// works in both IE and Firefox:document.getElementById("mytextarea").value = "title:\nparagraph:";

  2. Sorry I didn't explain my self correctlyWhat I meant by 5 is I had to delete 5 character at the end of $_SERVER['PHP_SELF'] to delete the .php but I only see 4 character when I echo it!I didn't count the first slash because it was not in the $maxcount variable.
    I think I understood you correctly. You're asking why you have to subtract 5 rather than 4. Maybe another example will help. Think about this code instead:
    $startpos = 1;$extension = ".php";$strlength = strlen($_SERVER['PHP_SELF']) - strlen($extension);$name = substr($_SERVER['PHP_SELF'], $startpos, ($strlength - $startpos));

  3. I guess if Render is only available in 2.0 and up and if you are in 1.1, you might try putting the page display in a control and then use your RenderControl method:

    <asp:Panel id="PageContentPanel" runat="server"><!-- Page contents go here --></asp:Panel>

    Then, in the code:

    StringWriter writer = new StringWriter();HtmlTextWriter htmlWriter = new HtmlTextWriter(writer);PageContentPanel.RenderControl(htmlWriter);return writer.toString();

  4. I'm using 1.1 (at work) and there is no Page.Render only Page.RenderControl I'll have to check whne I get home (I have 2.0 at home) to see if it is there.
    We use 2.0 here at work and it is there but I haven't ever fiddled with it. I know there's gotta be a way to render a page on the server to get its contents. I just haven't tested that Page.Render() method.Another alternative could be something like this:
    string url = "http://www.w3schools.com/default.asp";System.Net.WebClient client = new System.Net.WebClient();string html = client.DownloadString(url);

    But I just have to think that there should be a way to get the rendered contents of an aspx page without having to resort to an HTTP request.

  5. error: Server Error in '/1' Application.--------------------------------------------------------------------------------A potentially dangerous Request.Form value was detected from the client (TextBox1="<html><HEAD><TITLE>U...").
    Hah, the HttpRequestValidationException. I was just working with that yesterday. To allow HTML to be submitted to your form, set the ValidateRequest="true" in the page declaration:
    <%@ Page Language="C#" CodeFile="MyPage.aspx.cs" Inherits="MyPage" ValidateRequest="false" %>

    But, before you do that, try calling Page.Render(htmlWriter) rather than Page.RenderControl(htmlWriter) like I posted above.

  6. If you are talking about ASP.NET (i.e. web-based) then printing is a client-side function that happens in the browser; the only thing you'd be able to do in ASP.NET is to send the following javascript to run on the client-side:

    <script type="text/javascript">window.print();</script>

    Generating a PDF, however, isn't a bad idea. You could generate the PDF and send it to the user for downloading. For more info on generating PDFs, check Google: http://www.google.com/search?q=asp.net+pdf+generator

  7. What about calling Render() on the Page instead of RenderControl()? If I had more time at the moment I'd play around with this but for now I just have to toss you ideas and hope they work! :)

    StringWriter writer = new StringWriter();HtmlTextWriter htmlWriter = new HtmlTextWriter(writer);Page.Render(htmlWriter);return writer.toString();

  8. So, just so I have this straight, the data in your tables looks something like this?

    Blog_01	Blog_01ID	Blog_01_Category-----------------------------------------	  4			   Programming	  5			   Programming	  6			   Travel	  7			   EducationBlog_01_Category	Blog_01_CategoryID	Blog_01_Category-------------------------------------------	  1							 Programming	  2							 Travel	  3							 Education

    If that's the case, your SQL query would have to look more like:

    SELECT * FROM Blog_01 WHERE Blog_01_Category LIKE 'Programming'

    On the other hand, if your Blog_01 table looked like this:

    Blog_01	Blog_01ID	Blog_01_CategoryID-----------------------------------------	  4			   1	  5			   1	  6			   2	  7			   3

    Then, to get all of the entries that were in "Programming" you would do this:

    SELECT * FROM Blog_01 WHERE Blog_01_CategoryID = 1

    If you also wanted to get the category information you could use an INNER JOIN to the category table on that category ID:

    SELECT Blog_01.*, Blog_01_Category.Blog_01_CategoryFROM Blog_01	INNER JOIN Blog_01_Category ON Blog_01.Blog_01_CategoryID = Blog_01_Category.Blog_01_CategoryIDWHERE Blog_01.Blog_01_CategoryID = 1

    There will eventually be two queries: One query to get the categories to display in your navigation and another query to display all the posts in a particular category.

  9. I don't know how you have your data set up, but typically the table structures in the database would look a bit like this:

    BlogCategories------------------	CategoryID	CategoryTitle	CategoryDescriptionBlogEntries-----------------	EntryID	CategoryID	EntryText	Date

    The CategoryID in the BlogEntries table would match the CategoryID for one of the entries in the BlogCategories table.When a new entry was made for the blog, you'd select a category from your dropdown menu. The dropdown menu would have the "CategoryTitle" as the display text and the "CategoryID" as the value. When the entry was saved in the database, the CategoryID that matched the category that was chosen would be saved in that row in the BlogEntries table. This way, when you wanted to see all the entries that were made in that category, you'd just look for those entries with that particular CategoryID (like that query that I posted).

  10. For future reference, you can also use a RegularExpressionValidator:

    <asp:RegularExpressionValidator ID="v_txtNumeric" runat="server" ControlToValidate="txtNumeric" ValidationExpression="[0-9]*" ErrorMessage="The value must be numeric!" /><asp:TextBox id="txtNumeric" runat="server"/>

    Or a CompareValidator:

    <asp:CompareValidator ID="v_txtNumeric" runat="server" ControlToValidate="txtNumeric" Operator="DataTypeCheck" Type="Integer" ErrorMessage="The value must be numeric!" /><asp:TextBox id="txtNumeric" runat="server"/>

  11. Like justsomeguy said, nothing is going to happen on your page until it posts back to the server. You can automate this (so that the user doesn't have to click a submit button) by modifying your DropDownList like so:

    <asp:DropDownList ID="DropDownList1" runat="server" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" AutoPostBack="true">

    Otherwise, you'll have to use javascript to make those fields appear and disappear.

  12. If your Blog_01 table has a Blog_01CategoryID like the Blog_01_Category table does, you can get all the entries that are of a particular category (e.g. a category with an ID of 10) like this:

    SELECT * FROM Blog_01 WHERE Blog_01CategoryID = 10

  13. I like me some puzzles and brain teasers so I thought I'd give this one a try. I found this post that might help:http://groups.google.com/group/microsoft.p...9641f04834ad4bbThe poster suggests that adding SET ROWCOUNT 0 before the query helps prevent inconsistent recordsets. I'll keep poking around unless/until you post a solution.EDIT: I found this knowledgebase article as well. It talks about the MDAC and using Text or Blob for the data types in SQL Server. Is your "description" field a Text or Blob? Here's the link:http://support.microsoft.com/default.aspx/kb/175239

  14. * do you know why in my function I have to subtract 5 instead of 4?
    Because there are 5 characters that you no longer want: /, ., p, h, and p and rather than starting at position 0 for the substring, you are starting at position 1.You can think of it like this:The length of ".php" = 4.The length of "/apage" = 6If you start at 1, then the length of the substring that you want is 1 less than it's current length (6). So, you subtract 4 for the ".php" and another 1 for the beginning "/".I hope that helped!
  15. I use this to automatically attempt to upload the file as soon as the user selects a file from his/her filesystem:

    <form id="theForm" enctype="multipart/form-data"><input type="file" id="theFile" onchange="document.getElementById('theForm').submit();" /></form>

  16. If you plan on developing this further, I'd like to offer a suggestion. Create two tables.Something like this:

    Users--------- UserID FirstName LastNameMessages--------- MessageID UserID MessageText
    This way, each message is associated to a particular user - through that UserID - so if you ever wanted to be able to determine how many messages, for example, each user had submitted, you could count the number of records in your Messages table that had a particular UserID.Good luck!
  17. Well, it looks like the winner is scrollWidth.Even though there aren't any scrollbars, turns out the browser keeps track of how wide the scroll width would be if there were scrollbars.So, just in case anyone else ever runs into this problem, here's how you can do it:

    var element = document.getElementById("test");if(element.offsetWidth >= element.scrollWidth){	// no clipping occurred.}else{	// content overflowed.}

×
×
  • Create New...