Click here to Skip to main content
13,668,551 members

Comments by jon-80 (Top 49 by date)

jon-80 18-Jun-14 6:34am View
   
Well this is helpful however, I was actually reading XML not writing :)
jon-80 19-Feb-12 3:12am View
   
Well, it does not quite work well, somehow, since only the number key 1 seems to work, any idea why?

<pre>

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace TestApplication
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();

//initialize keyboard shortcuts (1 to 9, the decimal point, and, multiplication operators (+,-,*,/)
this.btn1.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.btn1_KeyPress);
this.btn2.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.btn2_KeyPress);
this.btn3.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.btn3_KeyPress);
this.btn4.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.btn4_KeyPress);
this.btn5.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.btn5_KeyPress);
this.btn6.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.btn6_KeyPress);
this.btn7.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.btn7_KeyPress);
this.btn8.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.btn8_KeyPress);
this.btn9.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.btn9_KeyPress);
this.btn0.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.btn0_KeyPress);
this.btnDecimal.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.btnDecimalPoint_KeyPress);
this.btnAdd.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.btnAdd_KeyPress);
this.btnSubtract.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.btnSubtract_KeyPress);
this.btnMultiply.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.btnMultiply_KeyPress);
this.btnDivide.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.btnDivide_KeyPress);
}

private void btn1_KeyPress(object sender, KeyPressEventArgs e)
{
if(e.KeyChar == 49)
{
btn1.PerformClick();
}
}

private void btn2_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == 50)
{
btn2.PerformClick();
}
}

private void btn3_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == 51)
{
btn3.PerformClick();
}
}

private void btn4_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == 52)
{
btn4.PerformClick();
}
}

private void btn5_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == 53)
{
btn5.PerformClick();
}
}

private void btn6_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == 54)
{
btn6.PerformClick();
}
}

private void btn7_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == 55)
{
btn6.PerformClick();
}
}

private void btn8_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == 56)
{
btn1.PerformClick();
}
}
private void btn9_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == 57)
{
btn1.PerformClick();
}
}
private void btn0_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == 48)
{
btn1.PerformClick();
}
}
private void btnDecimalPoint_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == 46)
{
btnDecimal.PerformClick();
}
}
private void btnAdd_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == 43)
{
btnDecimal.PerformClick();
}
}
private void btnSubtract_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == 45)
{
btnDecimal.PerformClick();
}
}
private void btnMultiply_KeyPress(object sender, KeyPressEventArgs e)
{
i
jon-80 19-Feb-12 2:34am View
   
The code needs to exclude the (), otherwise VS will complain that ..KeyChar(), cannot be used like a method.

<pre>
this.btn1.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.btn1_KeyPress);

private void btn1_KeyPress(object sender, KeyPressEventArgs e)
{
if(e.KeyChar=='1')
{
//ur code
}
}
<pre>
jon-80 2-Aug-11 13:33pm View
   
That's fine, however I would like to be able to do it programmatically, by passing parameters that represent applications held in memory, and, interface directly with the Windows API, for example using the Clipboard API (http://msdn.microsoft.com/en-us/library/ms649012%28v=VS.85%29.aspx).
jon-80 27-Mar-11 2:04am View
   
Thanks
jon-80 20-Mar-11 17:58pm View
   
ok
jon-80 20-Mar-11 12:22pm View
   
Yes, because I am thinking that it might be a bug.
jon-80 12-Sep-10 9:57am View
   
Articles.aspx
-------------

<asp:Repeater ID="articles" runat="server">
<itemtemplate>
<asp:Calendar ID="calendarArticleDate" runat="server" BackColor="White"
BorderColor="#999999" CellPadding="4" DayNameFormat="Shortest"
Font-Names="Verdana" Font-Size="8pt" ForeColor="Black" Height="180px"
Width="200px">
<SelectedDayStyle BackColor="#666666" Font-Bold="True" ForeColor="White" />
<SelectorStyle BackColor="#CCCCCC" />
<WeekendDayStyle BackColor="#4AA02C" />
<TodayDayStyle BackColor="#CCCCCC" ForeColor="Black" />
<OtherMonthDayStyle ForeColor="#808080" />
<NextPrevStyle VerticalAlign="Bottom" />
<DayHeaderStyle BackColor="#CCCCCC" Font-Bold="True" Font-Size="7pt" />
<TitleStyle BackColor="#999999" BorderColor="Black" Font-Bold="True" />

<asp:TextBox ID="txtSubject" runat="server" Width="675px" Text='<%#Bind("Subject")%>'>

<asp:TextBox ID="txtEntryText" runat="server" TextMode="MultiLine" Height="450px" Width="675px" Text='<%#Bind("EntryText")%>'>




Articles.aspx.cs

protected void Page_Load(object sender, EventArgs e)
{

String _conn = "Data Source=ARMANI\SQLEXPRESS;Initial Catalog=couch_db;Integrated Security=True";
String _cmd = "SELECT [Timestamp],[Subject],[EntryText] FROM [couch_db].[dbo].[Article]";
SqlDataSource _ds = new SqlDataSource(_conn, _cmd);
articles.DataSourceID = _ds.ID;
//articles.DataBind();

}

Source code at http://cid-b712073b3513eb8e.office.live.com/self.aspx/.Public/dumps/Broken%20code%20-%20ASP.NET/Jon%5E4s%20Couch%202010-09-12.rar.

Screenshot at http://cid-b712073b3513eb8e.office.live.com/view.aspx/.Public/dumps/Broken%20code%20-%20ASP.NET/jon%5E4s%20blog%20-%20articles.aspx%20-%20scr.docx.
jon-80 12-Sep-10 9:26am View
   
Thanks, the only issue now is getting the repeater to display the data, because nothing is being displayed within the repeater.
jon-80 10-Sep-10 16:45pm View
   
The code is at http://cid-b712073b3513eb8e.office.live.com/self.aspx/.Public/dumps/Broken%20code%20-%20ASP.NET/Jon%5E4s%20Couch%202010-09-09.rar.

Error reads: The DataSource property cannot be set delcaratively.
jon-80 10-Sep-10 16:43pm View
   
NOTE: Cannot update hyperlinks within the 'Submit Comments'.

Source code at http://cid-b712073b3513eb8e.office.live.com/self.aspx/.Public/dumps/Broken%20code%20-%20ASP.NET/Jon%5E4s%20Couch%202010-09-10.rar
jon-80 10-Sep-10 16:42pm View
   
I tried something else, however it says that the 'DataSource' property cannot be set declaratively, since I'm using .NET 3.5.

Source code at updated here.

Repeater class doc here.

:confused:

NOTE: I can
jon-80 10-Sep-10 11:03am View
   
I tried this code, but a compilation warning is being displayed:
<asp:Repeater ID="Repeater1" runat="server">
<asp:TextBox ID="txtSubject" runat="server" Width="675px">

<asp:TextBox ID="txtEntryText" runat="server" TextMode="MultiLine" Height="450px" Width="675px">
jon-80 4-Sep-10 12:49pm View
   
My actual requirement is to have a <formview> that somehow binds to a datasource (SQL Server 2005), and, allows the user to read, edit, insert, update and delete from the form. If a form is not available, some kind of <textbox> or interface is good enough. This is really basic, I just can't figure out how to do it in ASP.NET.
jon-80 4-Sep-10 12:47pm View
   
Would you please add a code snippet or a link to a related article as an example?
jon-80 4-Sep-10 6:40am View
   
What's the correct way?
jon-80 4-Sep-10 5:42am View
   
Source code at http://cid-b712073b3513eb8e.office.live.com/self.aspx/.Public/dumps/Jon%5E4s%20Couch.rar
jon-80 4-Sep-10 5:33am View
   
I'm following MSDN articles at http://msdn.microsoft.com/en-us/library/6w2tb12s(v=VS.90).aspx - How to: Dynamically Bind Event Handlers at Run Time in ASP.NET Web Pages, and, http://msdn.microsoft.com/en-us/library/t3d01ft1(v=VS.90).aspx - How to: Dynamically Bind Event Handlers at Run Time in ASP.NET Web Pages.
jon-80 4-Sep-10 5:30am View
   
Thanks, so far the only issue is how to manually add the event handler for the button:

Articles.aspx
<asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True"
CommandName="Insert" Text="Insert" OnClick="InsertButton_Click" />

Articles.aspx.cs

public partial class Articles : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
this.Title = "Jon's Couch";

InsertButton_Click += new System.EventHandler(this.InsertButton_Click);

}

protected void InsertButton_Click(object sender, FormViewCommandEventArgs e)
{
if (e.CommandName == "new")
{
Envelope.DefaultMode = FormViewMode.Insert;
}
}
}
jon-80 3-Sep-10 2:57am View
   
Step 2 does not compile:
Object reference not set to an instance of an object.
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.NullReferenceException: Object reference not set to an instance of an object.

Step 4. It does not seems possible to call the user control from within the Page_Load of the .aspx Page (articles.aspx)

Source code at http://cid-b712073b3513eb8e.office.live.com/self.aspx/.Public/dumps/Jon%5E4s%20Couch.rar.
jon-80 2-Sep-10 6:29am View
   
Thanks.

IsPostback was not used, because when I was planning the logic, I wasn't bothered whether the Page was being loaded for the first time or as a postback (refresh).
jon-80 1-Sep-10 15:29pm View
   
FindControl doesn't seem to work with TextBoxes embedded within a FormView control.
jon-80 31-Aug-10 17:28pm View
   
Thanks for that, any idea what might work?
jon-80 31-Aug-10 8:36am View
   
thanks for your comment, however, it's just that I haven't stumbled across the adequate solution for my problem, dude
jon-80 31-Aug-10 8:35am View
   
Deleted
Rant...
jon-80 30-Aug-10 16:15pm View
   
Any code snippets?
jon-80 30-Aug-10 12:57pm View
   
"That is, the data within the remains unchanged, notwithstanding calArticles selection is changed"

This problem is freaking me out (:confused), coz it's intermittent. One minute the calendar updates the data when debugging. This seems to be an SQL issue however (maybe my logic)

SELECT [Timestamp], [Subject], [EntryText] FROM [Article] WHERE [Timestamp] >= '8/25/2010 12:00:00 AM' AND [Timestamp] < (DATEADD(day, 1, [Timestamp]));
jon-80 30-Aug-10 12:51pm View
   
Deleted
"That is, the data within the remains unchanged, notwithstanding calArticles selection is changed"
Well, the problem seems to be an oversight, but I still don't have a complete picture, I'll look into it...needs reading I guess.

Thanks anyway :)
jon-80 30-Aug-10 12:26pm View
   
"You provided source code, but, didn't provide your database backup."
No problem, I uploaded the .mdf file to http://cid-b712073b3513eb8e.office.live.com/self.aspx/.Public/dumps/couch%5E_db.rar

"You should try to remove the OnClick="btnSave_Click" event handler and see what happens"
When I tried that the form data is still not updated, and, I am not sure how to get the <formview> to read the @EntryID parameter:

UpdateCommand="UPDATE [Article] SET [Timestamp] = @Timestamp, [Subject] = @Subject, [EntryText] = @EntryText WHERE [EntryID] = @EntryID;"

The code that I tried, like the one within protected void calArticles_SelectionChanged, updates the SQL Statement correctly, however, I'm missing a link. How do I ask the <formview> to update the data based on this SQL Query. That is, the data within the <formview> remains unchanged, notwithstanding calArticles selection is changed.
jon-80 28-Aug-10 23:42pm View
   
lol, while thanking you for your comment, are you suggesting that I bind the data connection (say as per this article - http://support.microsoft.com/kb/307860), and, that I discard the datasource from the designer.

Any idea why Formview does not work, and, I think it is bound (somehow) because otherwise the data wouldn't appear on the form... just my logic...
jon-80 28-Aug-10 22:57pm View
   
Deleted
Do you have a code snippet, pls?
jon-80 28-Aug-10 14:39pm View
   
NOTE: Rendering of this code is unclear...
jon-80 28-Aug-10 14:16pm View
   
yeh, I'm still trying to figure out how to Edit, Save and Refresh the controls, because the textboxes are disappearing when I tried Editing...guess I need more research :)
jon-80 28-Aug-10 13:28pm View
   
thanks for that; I did try some code but somehow it's not binding..


<ItemTemplate>
<p> <asp:TextBox runat="server" Width="1000" ReadOnly="true" ID="txtSubject" Text='<%# Eval("Subject")%>'></asp:TextBox> </p>
<p> <asp:TextBox runat="server" Height="300" Width="1000" ReadOnly="true" ID="txtBody" TextMode="MultiLine" Text='<%# Eval"EntryText" %>'></asp:TextBox>
</ItemTemplate>
</asp:FormView>


I'll go through the article again and see if anything else makes sense :)
jon-80 28-Aug-10 13:19pm View
   
10x
jon-80 28-Aug-10 13:13pm View
   
Deleted
10x, but I would rather have someone actually read through my problem before replying...
jon-80 28-Aug-10 8:42am View
   
"You should also not be string mashing SQL in your presentation layer, not if you want to write scalable and maintainable code."
I agree, it's bad design, however, this is just a personal blog, so I'm taking a minimalist approach to prove the concept works :) How would you suggest passing the SQL statements to the database?
jon-80 27-Aug-10 16:14pm View
   
Thanks for the explanation. Do you think I'd be able to convert Environment.NewLine to a char[], because that's what I would require if I were to use Environment.NewLine. If yes, how?
jon-80 26-Aug-10 3:15am View
   
No
jon-80 25-Aug-10 19:57pm View
   
I can't update the properties, because the only code that I can see from the designer is minimal, so I'm not sure how to "get to the contents of the user control".

Diary.aspx
....
<uc1:CalendarBrowse ID="CalendarBrowse1" runat="server" />
....
jon-80 25-Aug-10 19:56pm View
   
Deleted
The problem is that when I use the user control, the only code that I am able to see within the designer does not allow me to change the code:

Diary.aspx
...
<uc1:CalendarBrowse ID="CalendarBrowse1" runat="server" />
...

CalendarBrowse.ascx
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="CalendarBrowse.ascx.cs" Inherits="CalendarBrowse" %>
<asp:Calendar ID="Calendar1" runat="server" BackColor="White"
BorderColor="#999999" CellPadding="4" DayNameFormat="Shortest"
Font-Names="Verdana" Font-Size="8pt" ForeColor="Black" Height="180px"
Width="200px">
<SelectedDayStyle BackColor="#666666" Font-Bold="True" ForeColor="White" />
<SelectorStyle BackColor="#CCCCCC" />
<WeekendDayStyle BackColor="#4AA02C" />
<TodayDayStyle BackColor="#CCCCCC" ForeColor="Black" />
<OtherMonthDayStyle ForeColor="#808080" />
<NextPrevStyle VerticalAlign="Bottom" />
<DayHeaderStyle BackColor="#CCCCCC" Font-Bold="True" Font-Size="7pt" />
<TitleStyle BackColor="#999999" BorderColor="Black" Font-Bold="True" />


<asp:FormView ID="Envelope" runat="server" DataSourceID="XmlDataSource1"
AllowPaging="True">
<headertemplate>

<itemtemplate>

<asp:TextBox runat="server" Width="1000" ReadOnly="true" ID="txtSubject" Text='<%# XPath("/articles/article/subject") %>'>


<asp:TextBox runat="server" Height="300" Width="1000" ReadOnly="true" ID="txtBody" TextMode="MultiLine" Text='<%# XPath ("/articles/article/body")%>'>




<asp:Button ID="btnFirst" runat="server" Text="|<" Enabled="True" />
 <asp:Button ID="btnPrev" runat="server" Text="<<" Enabled="True" />
 <asp:Button ID="btnNext" runat="server" Text=">>" Enabled="True" />
 <asp:Button ID="btnLast" runat="server" Text=">|" Enabled="True" />



<asp:Button ID="btnNew" runat="server" Text="New" />
 <asp:Button ID="btnSave" runat="server" Text="Save" />
 <asp:Button ID="btnRefresh" runat="server" Text="Refresh" />
 <asp:Button ID="btnDelete" runat="server" Text="Delete" Enabled="False" />




<asp:TextBox ID="TextBox2" runat="server" Width="211px">
<asp:Button ID="btnSearch" runat="server" Text="Search" />




<asp:Label ID="lblFooter" runat="server">




<asp:XmlDataSource ID="XmlDataSource1" runat="server"
DataFile="~/App_Data/article.xml">
jon-80 25-Aug-10 19:53pm View
   
Environment.NewLine returns a string; I need to write CRLF after the xml end tag.
jon-80 22-Aug-10 7:17am View
   
Any idea how?
jon-80 18-Aug-10 1:43am View
   
excuse me
jon-80 17-Aug-10 15:03pm View
   
I'll see what I can figure out with text boxes, it would be nice if I could get a custom control, because actually that was my original intention; create a calendar that is linked to a database, which triggers data being loaded in a journal like fashion, however I am still thinking out how to go about it.

Are you using .NET 3.5 as well?
jon-80 17-Aug-10 15:01pm View
   
well it must be that my workhorse running Win XP SP3 over .NET Framework 3.5 (+3.5 SP1) doesn't like the control, coz I'm still getting the same error. What environment are you using?
jon-80 17-Aug-10 11:32am View
   
hmm...doesn't work, because I get an error reading that I need to place the calendar within tags, and, it seems that it is not possible to place them within a content page.

diary.aspx
<asp:Content ID="Content2" ContentPlaceHolderID="body" Runat="Server">
    <asp:Calendar ID="Calendar1" runat="server"></asp:Calendar>
</asp:Content>


Error displayed when I select My Diary (lhs)

Server Error in '/Jon's Couch' Application.

Control 'ctl00_body_Calendar1' of type 'Calendar' must be placed inside a form tag with runat=server.

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: Control 'ctl00_body_Calendar1' of type 'Calendar' must be placed inside a form tag with runat=server.

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): Control 'ctl00_body_Calendar1' of type 'Calendar' must be placed inside a form tag with runat=server.]
System.Web.UI.Page.VerifyRenderingInServerForm(Control control) +8689827
System.Web.UI.WebControls.Calendar.Render(HtmlTextWriter writer) +147
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +134
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19
System.Web.UI.Control.Render(HtmlTextWriter writer) +10
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +134
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19
System.Web.UI.Control.Render(HtmlTextWriter writer) +10
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +134
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19
System.Web.UI.Page.Render(HtmlTextWriter writer) +29
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1266


A tag cannot be placed within the ContentPlaceHolder, because it seems to conflict with the tag within the MasterPage, MasterPage.master.
jon-80 17-Aug-10 11:12am View
   
Thanks :)
jon-80 4-Jul-10 22:00pm View
   
Dumb answer

Advertise | Privacy | Cookies | Terms of Service
Web06-2016 | 2.8.180820.1 | Last Updated 1 Jan 1900
Copyright © CodeProject, 1999-2018
All Rights Reserved.
Layout: fixed | fluid