|
The easiest way to do both is:
to make the file extension add a deployment project (to create a installer) go to the file type editor and add the details about extensions, commands and what not. when you run the setup the file association will be made for you, complete with icons etc etc
As for a file format, have you considered using a Dataset to store your recipe internally. You can validate the "file format" with schema's and you can read and write datasets to disk with the XML functions. You can easily share them with other apps etc, and they provide a nice logical way to manage a recipe.
|
|
|
|
|
I didn't know you could do that! I'll look into XML, so would you still just use an xmlreader? I'm not a complete newb to programming but am to working with files.
Thanks
|
|
|
|
|
No not a XMLReader.
Define your recipe as a dataset (drag on onto your form), go to properties and set the table, then set the columns in the table.
Add a row, filling it with the recipe information the user enters (i assume)
to save it to disk use DataSetName.WriteXML(name of file here)
if the user want's to open the dataset use the ReadXML method of your dataset passing it the filename to open. you can get this as a command line argument to your app.
MSDN or Google: Dataset.WriteXML, DataSet.ReadXML, C# Command Line Arguments, SaveFileDialog, OpenFileDialog
Sorry it is brief but I am about to run out. I will be back in an hour if you still have no luck, but the MSDN documentation for dataSets and XML is great
|
|
|
|
|
Ok, now I understand what you were talking about. I will fool with it for a few days and if I don't have any luck I'll post back. I'll give it a shot. Thank you.
|
|
|
|
|
Could you point me to relevant examples on using xml stuff and datasets?
|
|
|
|
|
When I run my ASPX page I receive the following error message:
Server Error in '/test' Application.
--------------------------------------------------------------------------------
A page can have only one server-side Form tag.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: A page can have only one server-side Form tag.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[HttpException (0x80004005): A page can have only one server-side Form tag.]
System.Web.UI.Page.OnFormRender(HtmlTextWriter writer, String formUniqueID)
System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer)
System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer)
System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output)
System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer)
System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer)
System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output)
System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
System.Web.UI.Control.Render(HtmlTextWriter writer)
System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
System.Web.UI.Page.ProcessRequestMain()
I only have one form tag throughout the whole project so I really don't understand what it's complaining about.
Thanks!
Jane
|
|
|
|
|
Hi there,
IMO, the error is describing pretty well. You might have 2 forms with the runat='server' attribute. Can you post the form's code here?
<< >>
|
|
|
|
|
Do you think it's talking about the two "runat" I have in the following code:
<asp:datagrid id="_gdl
" width="100%"
="" runat="server" allowcustompaging="true" allowpaging="true" onpageindexchanged="Grid_Change" pagesize="10
">
If so, then should I delete " Runat="server" "?
Thanks!
|
|
|
|
|
Are you using master page??
<< >>
|
|
|
|
|
Hmm. If I new what master page was I could tell you. When I deleted " Runat="server" " I didn't receive the error message anymore. Now I have initialize _gdl.VirtualItemCount somewhere because it doesn't like that.
As far as I know VirtualItemCount is a predefined function. When I place my cursor over the function, the tool tip says "Gets or sets the virtual number of items in the System.Web.UI.WebControls.Datagrid control when custom paging is used".
This is the first chunk of code I have after defining the namespace:
public class DataGridPage : Page
{
private int _startIndex=0;
protected DataGrid _gdl;
protected void Page_Load(object Src, EventArgs e)
{
if (!IsPostBack)
{
_gdl.VirtualItemCount = GetItemCount();
_startIndex = _gdl.VirtualItemCount-_gdl.PageSize;
BindGrid();
}
}
Thanks!
Jane
|
|
|
|
|
Hi,
I have a little Generic problem.
Look a this very simplified Composite Pattern:
public abstract class BaseClass
{
}
public class Leaf
{
}
public class LeafA : Leaf
{
}
public class LeafB : Leaf
{
}
public class Composite<TChild> where TChild : BaseClass
{
private List<TChild> _children = new List<TChild>();
public List<TChild> Children { get { return _children;}}
}
Now in the main program I create a sample tree structure:
Composite<BaseClass> root = new Composite<BaseClass>();
root.Children.Add(new LeafB());
root.Children.Add(new LeafA());
Composite<LeafA> comp = new Composite<LeafA>();
comp.Children.Add(new LeafA());
comp.Children.Add(new LeafA());
root.Children.Add(comp);
comp = new Composite<LeafB>();
comp.Children.Add(new LeafB());
comp.Children.Add(new LeafB());
root.Children.Add(comp);
How i can check, if the childnode is a Composite ?
I ever get back a null
foreach (BaseClass b in root.Children)
{
if (b is Leaf)
{
}
else
{
Composite<BaseClass> child = (b as Composite<BaseClass>);
}
}
How I can solve this ?
thx for your help
Roger
|
|
|
|
|
When running my aspx page that uses C# programming I receive the following error message:
Server Error in '/test' Application.
--------------------------------------------------------------------------------
Specified cast is not valid.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidCastException: Specified cast is not valid.
Source Error:
Line 50: {
Line 51: conn.Open();
Line 52: count = (int)cmd.ExecuteScalar();
Line 53: }
Line 54: finally { conn.Dispose(); }
Source File: c:\inetpub\wwwroot\test\test.aspx.cs Line: 52
Stack Trace:
[InvalidCastException: Specified cast is not valid.]
test.DataGridPage.GetItemCount() in c:\inetpub\wwwroot\test\test.aspx.cs:52
test.DataGridPage.Page_Load(Object Src, EventArgs e) in c:\inetpub\wwwroot\test\test.aspx.cs:35
System.Web.UI.Control.OnLoad(EventArgs e)
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Page.ProcessRequestMain()
What can I do so that I won't get this message and can finally see if the data is being loaded into my ASPX page properly? I checked on Microsoft's website to see what it means but it's like reading stereo instructions.
Thanks!
Jane
|
|
|
|
|
Hi there,
IMO, try to delete all file in debug folder and rebuild then the project....
Gud luke
<< >>
|
|
|
|
|
Thanks for the advice but that didn't work. I'm grabbing data from my local SQL server and I just want to post it. Do you need my code?
Jane
|
|
|
|
|
Nevermind, someone else's solution eliminated the problem.
Thanks for your help!!
Jane
|
|
|
|
|
Happy coding ...
<< >>
|
|
|
|
|
change the code on line 52:
count = (int)cmd.ExecuteScalar();
to
count = Convert.ToInt32(cmd.ExecuteScalar());
|
|
|
|
|
Woohooo! That eliminated the error message. Thank you very much! Now I just have to get past another one.
Jane
|
|
|
|
|
Hi..
i have a Class, that has 3 DataMembers, all three are Static...
whenever i try to Serialize her, the output XML is EMPTY!
Please do help,
Here is the Class code, and Xml Serializer code...
The Class
-------
using System;
using System.IO;
using System.Xml;
using System.Runtime.Serialization.Formatters.Binary;
using System.Xml.Serialization ;
namespace ShipurSherut
{
[Serializable]
public class AppSettings
{
public static String Merhav;
public static String Yeud;
public static String ServerAddress;
static AppSettings()
{
}
}
}
The Xml Serializer:
--------------
public static void ToXml(Object objToXml,string filePath,bool includeNameSpace)
{
StreamWriter stWriter=null;
XmlSerializer xmlSerializer;
try
{
xmlSerializer = new XmlSerializer(objToXml.GetType());
stWriter = new StreamWriter(filePath);
if (!includeNameSpace)
{
System.Xml.Serialization.XmlSerializerNamespaces xs= new XmlSerializerNamespaces();
xs.Add("","");//To remove namespace and any other inline information tag
xmlSerializer.Serialize(stWriter, objToXml,xs);
}
else
{
xmlSerializer.Serialize(stWriter, objToXml);
}
}
catch(Exception exception)
{
throw exception;
}
finally
{
if(stWriter!=null) stWriter.Close();
}
}
|
|
|
|
|
If you only have static fields, there is no data in the object, so there is nothing to serialize.
---
b { font-weight: normal; }
|
|
|
|
|
So, Maybe i missunderstood the whole meaning of Static.. i thought a claasic datamembers , let's me , save my data at a class, that don't need and instance in order for me to read the data... a sort of public class. that i can approach from every class in my project./
in that case , i wanted to take the data from my xml file( the application settings) and then use it in multiple classes, without havin the need to open instances of the same class , and double my data....
am i missing the propuse of the static class?
|
|
|
|
|
No, that is correct. The static members reside in the class. But you are serializing an object, not the class.
---
b { font-weight: normal; }
|
|
|
|
|
ok, How can i serialize the class?
|
|
|
|
|
You can't serialize a class, as a class can not be dynamically created.
One way to serialize the static information could be to put the fields in a separate class, and put a static instance of that class in the original class:
public class MyInfo {<br />
string info, moreInfo, excessInfo;<br />
}<br />
<br />
public class MyClass {<br />
static MyInfo info = new MyInfo();<br />
}
Then you can add serialization to the info class, and serialize the static instance.
---
b { font-weight: normal; }
|
|
|
|
|
Man, i can't find the words , to express my gratitude...
i'm programming alone, a messy project.
i got no experiance in c#, and i can't ask anyone i know for help, cause they don't prog... and if they are,, not c#...
anyhow, Thank you... it works FINE! , i did exactly what you told me...
Bye - Yosi!
|
|
|
|