|
Hello,
I am trying to convert an Asp.Net XML sitemap file in a Google XMl sitemap file using a XSL file using an HttpHandler.
Everything seems well in my code but I am getting an error:
XML Parsing Error: not well-formed
Location: http://localhost:1132/WebSite/Google
Line Number 2, Column 62:<urlset xmlns="http://www.google.com/schemas/sitemap/0.84" />
I tried to display it as Text instead of Text/XML. I don't get the same error. I just get a bunch of squares after the line:
Line Number 2, Column 62:<urlset xmlns="http://www.google.com/schemas/sitemap/0.84" />
Could somebody help me out? I tried everything I could think of for the past 2 days.
I post my entire code in this post.
Thanks,
Miguel
--------- HttpHandler --------
Public Class SiteMap : Implements IHttpHandler
' -- [Methods] -------------------------------------------
' Define handler process request
Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
' Create ASP.NET web site map
Dim webSiteMap As XmlDocument = New XmlDocument
' Load ASP.NET's site map
webSiteMap.Load(HttpContext.Current.Server.MapPath(ConfigurationManager.AppSettings("~/Web.sitemap"))
' Create google xsl document
Dim googleXsl As XslCompiledTransform = New XslCompiledTransform
' Load google xml document
googleXsl.Load(HttpContext.Current.Server.MapPath("~/SiteMap.xsl"))
' Create xsl arguments list
Dim googleXslArguments As XsltArgumentList = New XsltArgumentList
googleXslArguments.AddParam("Domain", "", "http://www.domain.com")
' Create the ASP.NET's site map memory stream
Dim webSiteMapStream As MemoryStream = New MemoryStream
' Transform Asp.Net's site map to Google's site map and add it to stream
googleXsl.Transform(webSiteMap, googleXslArguments, webSiteMapStream)
' Output Google sitemap
context.Response.Clear()
context.Response.ContentType = "text/xml; charset=utf-8"
context.Response.Write(Encoding.UTF8.GetString(webSiteMapStream.GetBuffer))
context.Response.End()
End Sub
' Define is handler is reusable
Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
Get
Return False
End Get
End Property
End Class
--------- XSL --------
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.google.com/schemas/sitemap/0.84"
xmlns:dk="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:param name="By27.WebSite.Url"/>
<xsl:template match="dk:*"/>
<xsl:template match="@*|text()|comment()"/>
<xsl:template match="/">
<xsl:element name="urlset">
<xsl:apply-templates select="//dk:siteMapNode[@google='true']"/>
</xsl:element>
</xsl:template>
<xsl:template match="dk:siteMapNode">
<xsl:element name="url">
<xsl:element name="loc">
<xsl:value-of select="$Domain" />
<xsl:value-of select="substring(@url, 3)"/>
</xsl:element>
<xsl:element name="lastmod">
<xsl:value-of select="@lastmod"/>
</xsl:element>
<xsl:element name="changefreq">
<xsl:value-of select="@changefreq"/>
</xsl:element>
<xsl:element name="priority">
<xsl:value-of select="@priority"/>
</xsl:element>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
|
|
|
|
|
Hello,
I am creating VS2005 web project which includes various custom controls.
One of those controls uses a XSL file.
How can I embed the XSL file in my .dll so I don't need to place it in all my web sites?
Thanks,
Miguel
|
|
|
|
|
If your custom controls are in a seperate project you can add the XSL file as an embedded resource. Or you can place it in a resource file in the web project.
only two letters away from being an asset
|
|
|
|
|
Hi Guys,
I'm new in ASP.net. I'm trying to write a web application that has a login. For each login, they will see different function and information. The question is do you guys have any suggestions of what I should use? Can you give me a starting point or an article about this that I can refer to?
Thank you much
|
|
|
|
|
Session variable work very well for this. You should be able to find plenty of articles on the use of session variables. It should work something like this.
Login - The user enters there details into a couple of textboxes
Validate - You get the details from the textbox and check them against a database containing all login info.
Set session variables. - You set the session variables up. Eg one called Username to hold the users name, one called usergroup to hold the group the user is in ( to determine permissions)
Forward User - forward the user to the page they should see after login
Then on every page that needs to validate the user, add to the Page load event a script that gets the users group setting from the session variable. Usually the best way to run through permissions would be to use a select statment (vb) or switch statement (c#), which would perform different setups depending on the users group setting. Usually this would be done using the visible attribute of each control required for the user.
I hope that makes sense. I did kind of rush what is quite a complex subject.
One other things. If you want to save time and coding when validating a user into each page, place the code that performs this in a masterpage. Obviously this will only work for global requirements, but in a scenario with a menu this is perfect.
|
|
|
|
|
Sam Heller wrote: If you want to save time and coding when validating a user into each page, place the code that performs this in a masterpage.
Why not use the Login Control and/or Forms Authentication that is built in? Easier than trying to re-invent the wheel.
only two letters away from being an asset
|
|
|
|
|
Hi,
I am a novice to the Ajax world. I am currently working on ASP.net 1.1 with C#.
I would like to add Ajax features to my app.
There seems to be a lot of options to pick from. I am not clear what works with ASP.Net 1.1 version too.
My main objectives are:
1. Has to work with ASP.NET 1.1
2. I dont want to write the generic portion of Javascript.
[I don't mind writing code for my own functionality. But I would like to have pre-built generic function(with documentation).]
3. I want a mature framework that has been tested well on other apps with common issues resolved.
4. Cross-Browser support for commonly used browsers .(IE, Firefox , Opera, Safari) .
5. I am seeing a lot Ajax container implementation.
What is the advantage/limilation of using an Ajax container vs an Ajax Framework.
Can someone help me to decide what framework/approach I should take.
Many thanks.
|
|
|
|
|
|
Are you sure you can use Atlas with version 1.1. I was under the impression it would only work with version 2.0???????
|
|
|
|
|
Hey,
Having some issues catching events from a Datalist. The main reason for this is due to the Datalist being embedded inside another datalist. I can grab all the events from the Outer Datalist no problems(one of which hides and shows the inner data list). I have a save button and some checkboxes in the inner datalist and need to catch all of their relvant events.
Any Ideas? I dont even know where to start on this?
Here is the page code
Thanks
<asp:DataList ID="OuterDataList" runat="server" DataSourceID="XmlDataSource1" OnSelectedIndexChanged="OuterDataList_SelectedIndexChanged" ><br />
<ItemTemplate><br />
<table style="border:solid 1px #CCCCCC;background-color:#EBEBEB;margin:5px 0px;"><br />
<tr><br />
<td style="padding:3px;width:700px;"><br />
<h2><%#DataBinder.Eval(Container.DataItem, "Month")%></h2><br />
</td><br />
<td><br />
<asp:ImageButton ID="ArrowImageButton" runat="server" CommandName="ShowOrHide" ImageUrl="../images/icons/Down%20Arrow%2016%20h%20g.gif" /><br />
</td><br />
</tr><br />
<tr><br />
<td colspan="2"><br />
<asp:DataList ID="InnerDataList" runat="server" DataSourceID="XmlDataSource2" Visible="false" CssClass="InnerDataList"><br />
<HeaderTemplate><br />
<table><br />
<tr><br />
<th style="width:120px;"><br />
Lead<br />
</th><br />
<th style="width:120px;"><br />
Ammount<br />
</th><br />
<th style="width:120px;"><br />
Date<br />
</th><br />
<th style="width:350px;"><br />
</th><br />
<th style="width:60px;"><br />
Paid<br />
</th><br />
</tr><br />
</HeaderTemplate><br />
<ItemTemplate><br />
<tr><br />
<td style="width:120px;"><br />
<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%#DataBinder.Eval(Container.DataItem, "Lead", "Lead.aspx?LID={0}")%>' style="color:Blue;"><%#DataBinder.Eval(Container.DataItem, "Lead")%></asp:HyperLink><br />
</td><br />
<td style="width:120px;"><br />
<%#DataBinder.Eval(Container.DataItem, "Ammount", "£{0}")%><br />
</td><br />
<td style="width:120px;"><br />
<%#DataBinder.Eval(Container.DataItem, "Date")%><br />
</td><br />
<td style="width:350px;"><br />
</td><br />
<td style="width:60px;"><br />
<asp:CheckBox ID="CheckBox1" runat="server" /> <br />
</td><br />
</tr><br />
</ItemTemplate><br />
<FooterTemplate><br />
<tr><br />
<td style="width:120px;"><br />
</td><br />
<td style="width:120px;"><br />
<label id="Total" runat="server">£867.30</label><br />
</td><br />
<td style="width:120px;"><br />
</td><br />
<td style="width:350px;"><br />
</td><br />
<td><br />
<asp:CheckBox ID="CheckBox1" runat="server" AutoPostBack="true" /><br />
</td><br />
</tr><br />
<tr><br />
<td colspan=4><br />
<asp:Button ID="Button1" runat="server" Text="Save" /> <br />
<asp:Button ID="Button2" runat="server" Text="PDF" CommandName="ShowPDF" /><br />
</td><br />
</tr><br />
</table><br />
</FooterTemplate><br />
</asp:DataList><asp:XmlDataSource ID="XmlDataSource2" runat="server" DataFile="~/xml/Copy of Recommended.xml"<br />
XPath="Accounting/Dues/Due"></asp:XmlDataSource><br />
</td><br />
</tr><br />
</table><br />
</ItemTemplate><br />
</asp:DataList>
|
|
|
|
|
You have to manipulate each control placed inside another List by using its ID.
for example:
You can reference the embedded Save Button instance and attach Click event by
Button saveButton=CType(DataList1.Items(0).FindControl("saveButton"),Button)
AddHandler saveButton.Click, AddressOf SaveButton_Click
|
|
|
|
|
Hi.
Last week I posted a question regarding reading Excel file and loading it into the DataGrid.
I didn't get any useful response back so please forgive me for posting this second time.
I'm sure someone had the same problem I have.
I have 3 columns in Excel. One of the columns (User Id) has text data (like: User 1) or a number data (like: 12345). My code works and doesn't throw any error but for some reason it only extracts text data. The numbers are missing and I'm not sure why. I've tried to foramt that columnt to TEXT only but it doesn't help. Just to be sure I looped through DataSet to make sure the values are there and of course they weren't.
Here's the code that reads Excel and loads data into DataGrid. Please help.
Thank you.
Try<br />
'Create DataSet and DataAdapter<br />
ds = New System.Data.DataSet<br />
da = New System.Data.OleDb.OleDbDataAdapter<br />
<br />
'Establish connection<br />
con = New System.Data.OleDb.OleDbConnection( _<br />
"provider=Microsoft.Jet.OLEDB.4.0; " & _<br />
"data source=" & Session("ExcelFilePath").ToString() & "; " & _<br />
"Extended Properties=Excel 8.0")<br />
<br />
'Create command<br />
cmdSelectExcel = New System.Data.OleDb.OleDbCommand("SELECT * FROM [Sheet1$] ORDER BY Company", con)<br />
<br />
'Open connection<br />
con.Open()<br />
<br />
'Exectue command through adapter<br />
da.SelectCommand = cmdSelectExcel<br />
da.Fill(ds, "[Sheet1$]")<br />
<br />
'Assign DataSourse of the DataGrid and bind it<br />
dg.DataSource = ds.Tables(0).DefaultView<br />
dg.DataBind()<br />
<br />
'Close Connection<br />
con.Close()<br />
Catch ex As Exception<br />
'Display error message<br />
lblError.Text = "Error: " & ex.ToString()<br />
lblError.Visible = True<br />
End Try
|
|
|
|
|
Do you have the facility on Access to fire a SQL command at the database. You can do this in MSSQL 2005 and it will show you the results as they would appear.
|
|
|
|
|
Not sure what you mean. I'm trying to read Excel file using OleDb.
|
|
|
|
|
I am curently using MSSQL server 2005. An option to this is MS SQL Server Management Studio which allows you to fire SQL queries straight at the database and then shows you the returned results. I often use this feature to test SQL prior to placing it in the code. Is there a similar feature in Acess that would allows this. If there is, and you perform this and retrieve the details with the numbers requested then you can be sure the problem is with the Oledbadapter or something in your code. Rather than the SQL or access.
Hope this makes more sense.
|
|
|
|
|
Thank you. I know that the problem is with OldeDb. Like I've mentioned before it doesn't retreive values from Excel, they are just empty. In my research I found out that when you use OldeDb to extract data from Excel it uses first column's format, which is text in my example. I just thought there's a way around it.
Thank you again. If you hear anything let me know. And if I find something out I'll pst it here.
Alex.
|
|
|
|
|
OK. I figured it out with the help of a samrt man of course.
Here's the code and it will work. I hope that I can save some time to others if they need to do the same thing I do now.
Enjoy.
Try<br />
'Create DataSet and DataAdapter<br />
ds = New System.Data.DataSet<br />
da = New System.Data.OleDb.OleDbDataAdapter<br />
<br />
con = New System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Session("ExcelFilePath").ToString() & ";Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1;MaxScanRows=0""")<br />
<br />
'Create command<br />
cmdSelectExcel = New System.Data.OleDb.OleDbCommand("SELECT c.[Company], c.[Journal Entry], c.[Vendor] FROM [Sheet1$] AS c ORDER BY c.[Company]", con)<br />
<br />
'Open connection<br />
con.Open()<br />
<br />
'Exectue command through adapter<br />
da.SelectCommand = cmdSelectExcel<br />
da.Fill(ds, "Company")<br />
<br />
'Assign DataSourse of the DataGrid and bind it<br />
dg.DataSource = ds.Tables(0).DefaultView<br />
dg.DataBind()<br />
<br />
'Close Connection<br />
con.Close()<br />
Catch ex As Exception<br />
'Display error message<br />
lblError.Text = "Error: " & ex.ToString()<br />
lblError.Visible = True<br />
End Try
|
|
|
|
|
I'm trying to find a definitive answer to this question:
How many users are allowed to view web reports on Crystal Reports 11 developer edition?
I keep getting different answers. Business Objects told me there was no limit however I keep reading online that there is in fact a limit.
I'm developing a website for our client that needs to generate PDF/excel reports for each of their sales reps(meaning each of their 1100 sales reps needs to have the ability to go onto the website and view their report).
The website will be located on one of our company servers but obviously, outside of our firewall.
Can I use crystal for this task of handling 1100 sales reps or is there a limit to the number of users who can use this? If not, can anyone recomend a better alternative?
Thanks.
-Goalie35
|
|
|
|
|
Hi May be this is not the appropriate place but still believe it will yield something. Pls guide me to a starting link for web promotion on search engine and marketing the web site for generating revenue.
Many thanks
Don't Quit
|
|
|
|
|
web promotion is very - very good and easy work for web site promotion if you want to gruid properly read on google search engine.Its make easy for you.
Pavan Pareta
|
|
|
|
|
Hi all,
can any one tell me the difference b/w DataGrid & Gridview webserver controls?
is there any site which explains me about .NET 2.0 server controls other than Microsoft.com?
Thanks,
Rahi Sharma
If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
The GridView replaces the DataGrid in ASP.Net 2.0. I'm guessing they changed the name because of the great deal or new funcionality built in to it since version 1.1. EG Sorting
|
|
|
|
|
I just had my most embarasing moment when I realised that I cant link to a website from an event handler.
Can you show me the code to transfer to(maybe codeproject.com) from an eventhandler using VB.net in an ASP.NET page
Soon to be famous black south african programmer
|
|
|
|
|
Response.Redirect("http://www.codeproject.com")
|
|
|
|
|
Hi there.......
I used validation controls in my aspx applicaion, in local machine it's working fine. If i uploaded in remote server, it is showing error..
If i use this,
means, in remote server validation controls are working fine, but button click event was not generated.........
Please help me.....
Thks n Advance
Sam.M
|
|
|
|