|
Hi,
Can someone tell me how to convert a string of HTML to display on an aspx page?
Example:
string strHTTP="HTTP://www.yahoo.com";
TextArea1.Value = Server.HtmlEncode(strHTTP);
Why will the above not return as a link on a aspx page?
Thanks....
zxcvbnm
|
|
|
|
|
Why on earth would it ?
HTMLEncode converts strings to HTML valid strings. For example, if I type in a strong tag here : this is strong text , the input from the textbox to the CP site is not HTML encoded, so you see the result of the HTML tag. I need to type > in order to show a > in my text. Presumably the 'Ignore HTML tags in this message (good for code snippets)' checkbox calls Server.HTMLEncode, or something similar, to do this conversion for me automatically.
To render a link, use a linkbutton, or just an anchor tag.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I am trying to convert Excel file to XML using C#. And the name of the Excel file is Contacts.xls and the SheetName is Contacts.
OleDbcmdSource.CommandText = "SELECT * FROM [" + Contacts + "$]";
The above code is where it gives me an error. I get an error that the name Contacts does not exist in the current context.
This is my Web.Config code: <connectionstrings>
<add name="ExcelConnectionString" connectionstring="Data Source=C:\Contacts.xls;Extended Properties=Excel 8.0;HDR=No;IMEX=1;Provider=Microsoft.Jet.OLEDB.4.0;">
|
|
|
|
|
Your code should read:
OleDbcmdSource.CommandText = "SELECT * FROM [Contacts$]";
'Contacts' is being used like a variable. If you have not declared a variable called 'Contacts' in your code, the compiler is going to throw an error.
Paul
|
|
|
|
|
Hi Paul,
Thank You so much for replying. Now the Contacts error does not show up but
I get an error on the following code:
OleDbadpSource.Fill(dsSource);//The error says OleDbException was unhandled by user code. Don't know what that means
My full code is as follows:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
BindData();
}
private void BindData()
{
DataSet dsLoginSourceGrid = GetLoginDataSet();
GridView1.DataSource = dsLoginSourceGrid.Tables[0];
GridView1.DataBind();
}
private string GetConnectionString()
{
string strConnectionString = ConfigurationManager.ConnectionStrings["ExcelConnectionString"].ToString();
return strConnectionString;
}
private DataSet GetLoginDataSet()
{
string ConnectionString = GetConnectionString();
OleDbConnection sqlconSource = new OleDbConnection(ConnectionString);
OleDbCommand OleDbcmdSource = new OleDbCommand();
OleDbcmdSource.Connection = sqlconSource;
OleDbcmdSource.CommandType = CommandType.Text;
OleDbcmdSource.CommandText = "SELECT * FROM [Contacts$]";
OleDbDataAdapter OleDbadpSource = new OleDbDataAdapter(OleDbcmdSource);
OleDbadpSource.SelectCommand = OleDbcmdSource;
DataSet dsSource = new DataSet();
OleDbadpSource.Fill(dsSource);
return dsSource;
}
}
|
|
|
|
|
An exception has been raised when you try to fill the DataSet.
What are the details of the error?
The error may be caused because you don't appear to be opening your connection. Add a line 'sqlconSource.Open();' after the line where you create an instance of your connection object. You may also want to consider wrapping your connection in a 'using' block so that it is closed and disposed automatically when it goes out of scope.
Paul
|
|
|
|
|
It tells me "Could not find installable ISAM" Further "OleDbException was unhandled by user code"
View Detail tells me System.Data.OleDb.OleDbException {"Could not find installable ISAM."}
|
|
|
|
|
What is the connection string you are using? I think the information in your original post got truncated...
Paul
|
|
|
|
|
<connectionstrings>
<add name="ExcelConnectionString" connectionstring="Data Source=C:\Contacts.xls;Extended Properties=Excel 8.0;HDR=No;IMEX=1;Provider=Microsoft.Jet.OLEDB.4.0;">
This is my Connection String from Web.Config file
|
|
|
|
|
This doesn't look right. Your connection string should look something like this:
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\MyExcel.xls;Extended Properties="Excel 8.0;HDR=Yes;IMEX=1";
Have a look at the following link to get more help with creating connection strings to Excel files:
http://www.connectionstrings.com/?carrier=excel
Paul
|
|
|
|
|
<connectionstrings>
<add name="ExcelConnectionString" connectionstring="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Contacts.xls;Extended Properties=Excel 8.0;HDR=Yes;IMEX=2"
="">
I changed it as it shows above. But the error is still there.
|
|
|
|
|
There still must be something wrong with your connection string.
Have you definitely got the syntax right?
Paul
|
|
|
|
|
What is this thing called DSN. Do I need to enter the excel spreadsheet in a DSN to make this thing work?
|
|
|
|
|
I cannot find the syntax error though.
|
|
|
|
|
|
No, that link is related to Visual Studio 6.0 SP4.
If you are not sure whether you can create a connection to an Excel file, try creating a Univeral Data Link (UDL) file. You can do this by creating a new text file on your desktop and then changing its extension to .udl. If you then double-click the file, you will be able to configure the connection. When you have finished configuring the connection, you can get the connection string by opening the .udl file in a text editor.
Paul
|
|
|
|
|
The title may not be right, but I don't know how to call it. I want to know how to make a class adapt to a particular of control at run time. I am building a rich textbox control similar to the one below.
http://www.codeproject.com/cs/miscctrl/richtextboxextended.asp
Everything works fine, but I don't want the control to adapt to the richtextbox at the time I am building it. I want the users to choose specific textbox when they drag the component to the form. In that case, when they drag the control to the form, only the toolbar portion will show, not the text area. From the toolbar property, they can choose the richtextbox to associate the component with. I want this type of functionality, in that case the richtextobx can be located anywhere in the form. It does not have to be located right below the toolbar.
|
|
|
|
|
I added a public value something like that
set { RichTextBox = value; }
From the control, I set the richtextbox visibility to false. I built it; it seemed to work fine. Now, when I dragged the control to the form, then dropped a richtextbox to test it. I can see a combo in the property where I can select that richtextbox name. However when I selected it, the program exited abruptly which seemed to be an exception to me.
|
|
|
|
|
I think you can debug the designer by opening up a second instance of VS and attaching the debugger to the instance you want to debug through Debug > Attach to Process, this should let you know more about the exception.
|
|
|
|
|
Hi all,
Well, i've got quite a trivial problem. In my case, the Form.Designer.cs file which should appear as if linked to the Form.cs file (as in 1 in the image) along wih the resx file in the solution explorer, has sort of broken the link (shown in 2 in the image). This means, the only file associated with the Form.cs is the Form.resx file, and the Form.Designer.cs stays out of it.
Here's how my solution explorer appears.
http://aravindaonline.atspace.com/sample.jpg
Consequently, the formatting of the Form are not visible in the development mode although it is seen during run time...
I just need to know how to link this back...;)
I'm sure this is way too easy for you all...
Thanx in advance!!!
A
|
|
|
|
|
I had the same problem before
and just add the Form.Designer.cs file to the project and it worked normally again (it seems you have the file too, because it works in the runtime as you said)
hope it's going to work for you too.
good luck
|
|
|
|
|
|
The only way I know of to do this is to edit the project file in a text editor (outside of Visual Studio).
You should see an entry in the project file like:
<Compile Include="Select_Scheme.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Select_Scheme.resx">
<DependentUpon>SplitButtonDemoForm.cs</DependentUpon>
</Compile>
<Compile Include="Select_Scheme.Designer.cs" /> You will need to change it to look like this:
<Compile Include="Select_Scheme.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Select_Scheme.resx">
<DependentUpon>SplitButtonDemoForm.cs</DependentUpon>
</Compile>
<Compile Include="Select_Scheme.Designer.cs">
<DependentUpon>SplitButtonDemoForm.cs</DependentUpon>
</Compile>
|
|
|
|
|
Hi,
I DownLoaded "TerminalControl" Project From This Site and I am Trying To Use This Project On Web Using WebClass Library. All Control are Displaying On Web except "Windows Custom Control Or Terminal Control" of This Project.
How To Solve This Problem Please Send a Reply....
Prabhu.R
|
|
|
|
|
Please help me.
I use Visual c# 2005.
I want to use some control with same name and diffrent index like control array.
Please tell me i can use what property of controls like DropDownList
Thanks in advance.
-- modified at 14:57 Monday 13th August, 2007
|
|
|
|