Jump to content

jesh

Members
  • Posts

    2,293
  • Joined

  • Last visited

Everything posted by jesh

  1. I think you're right that \n\r is better, but I believe the issue here is that .innerHTML was being used instead of .value. So, my post revised would look like this:document.getElementById("mytextarea").value = "title:\n\rparagraph:";
  2. 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:";
  3. jesh

    custom function

    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));
  4. 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();
  5. 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.
  6. Which method worked? Setting the page contents to the value of a text box and emailing that? Or calling the Render method on the Page?
  7. 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.
  8. 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
  9. 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();
  10. 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.
  11. Right, but it would fire when the user clicked the back button on his/her browser.
  12. 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).
  13. Have you tried the solution you posted here: http://w3schools.invisionzone.com/index.ph...ost&p=66685Rather than calling RenderControl on the GridView object, have you tried calling it on the Page? I don't know if it'll work, but you might try it: StringWriter writer = new StringWriter();HtmlTextWriter htmlWriter = new HtmlTextWriter(writer);Page.RenderControl(htmlWriter);return writer.toString();
  14. jesh

    Numeric Textbox

    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"/>
  15. 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.
  16. 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
  17. jesh

    ASP wierdness

    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
  18. jesh

    I Have a question...

    Websites that have .aspx file extensions are typically sites that were built using ASP.NET. Websites that have extensions of .jhtml are typically sites that were built with Java as the server side language.If you want to begin learning more about ASP.NET, check out the tutorial here: http://www.w3schools.com/aspnet/default.asp
  19. jesh

    custom function

    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!
  20. 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>
  21. Maybe something like this: SELECT * FROM Inventory WHERE id NOT IN (SELECT DISTINCT id FROM Hire)
  22. If you plan on developing this further, I'd like to offer a suggestion. Create two tables.Something like this: 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!
  23. It's probably because one of your columns (firstname or lastname or both) has a constraint on it (e.g. a primary key). You could start by removing that constraint.
  24. jesh

    Overflow Width

    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.}
  25. I responded to your post in the ASP section. If this is about .NET, we can continue discussion here instead of the ASP forum.
×
×
  • Create New...