Showing posts with label code. Show all posts
Showing posts with label code. Show all posts

Saturday, March 31, 2012

Submitting Form to Database

I have an ASP.Net page created with a table I made to look like a form
for our benefit request program. How do I code this properly to send
it to a table in our database.

For the sake of me learning how to do this lets just do short example
like. I have an aspx page with a label for name and a text box where
a user can input their name.

I have a database table called tblName with a column called name where
the submitted names go.

How do I code it so the name is submitted, a confirmation page is
shown and the data goes to the database when I click submit? Any help
is greatly appreciated.

Thanks,
BenIf you look at the ASP.NET QUICKSTART tutorials on the asp.net website, it
has lots of examples like this. QUICKSTARTS also installs as an option with
Visual Studio.
--
--Peter
"Inside every large program, there is a small program trying to get out."
http://www.eggheadcafe.com
http://petesbloggerama.blogspot.com
http://www.blogmetafinder.com
"Ben" wrote:

Quote:

Originally Posted by

I have an ASP.Net page created with a table I made to look like a form
for our benefit request program. How do I code this properly to send
it to a table in our database.
>
For the sake of me learning how to do this lets just do short example
like. I have an aspx page with a label for name and a text box where
a user can input their name.
>
I have a database table called tblName with a column called name where
the submitted names go.
>
How do I code it so the name is submitted, a confirmation page is
shown and the data goes to the database when I click submit? Any help
is greatly appreciated.
>
Thanks,
Ben
>

Submitting Form to Database

I have an ASP.Net page created with a table I made to look like a form
for our benefit request program. How do I code this properly to send
it to a table in our database.
For the sake of me learning how to do this lets just do short example
like. I have an aspx page with a label for name and a text box where
a user can input their name.
I have a database table called tblName with a column called name where
the submitted names go.
How do I code it so the name is submitted, a confirmation page is
shown and the data goes to the database when I click submit? Any help
is greatly appreciated.
Thanks,
BenIf you look at the ASP.NET QUICKSTART tutorials on the asp.net website, it
has lots of examples like this. QUICKSTARTS also installs as an option with
Visual Studio.
--
--Peter
"Inside every large program, there is a small program trying to get out."
http://www.eggheadcafe.com
http://petesbloggerama.blogspot.com
http://www.blogmetafinder.com
"Ben" wrote:

> I have an ASP.Net page created with a table I made to look like a form
> for our benefit request program. How do I code this properly to send
> it to a table in our database.
> For the sake of me learning how to do this lets just do short example
> like. I have an aspx page with a label for name and a text box where
> a user can input their name.
> I have a database table called tblName with a column called name where
> the submitted names go.
> How do I code it so the name is submitted, a confirmation page is
> shown and the data goes to the database when I click submit? Any help
> is greatly appreciated.
> Thanks,
> Ben
>

Submitting form with a unique ID

Hi All,

I'm looking for some information/code samples on how I can create a
simple web form that includes an auto-generated Unique ID on the form.

The form includes the following 3 fields (Unique ID, First Name and
Last Name). I have a SQL Server 2000 back-end with the table created
as follows:

UniqueID - numeric (9)
FirstName - varchar (50)
LastName - varchar (50)

Ideally I would like the user just to enter their First and Last Name
and the form automatically creates a Unique ID for them. Once they
type in their First/Last Name the user submits the information to the
database. I've managed to get the web form created so that it submits
the First/Last Name successfully but I can't think how to create the
Unique ID, ideally I'd like this to be based around the time/date of
submittal.

Any guidance would be much appreciated.

Thanks

ScottJames... If you declare an IDENTITY column, SQL will return a
uniqueID upon INSERT. If you want to generate your own
uniqueID you could do a concatenation of the MAC address of the
client ethernet card plus a timestamp.

Regards,
Jeff
>I've managed to get the web form created so that it submits
the First/Last Name successfully but I can't think how to create the
Unique ID, ideally I'd like this to be based around the time/date of
submittal.<

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Using a system generated GUID is quick and easy, although kinda long.
16 bytes minimum.

"James Brown" <i.m@.winning.com> wrote in message
news:1f88a50b.0307051028.3caafaf1@.posting.google.c om...
> Hi All,
> I'm looking for some information/code samples on how I can create a
> simple web form that includes an auto-generated Unique ID on the form.
> The form includes the following 3 fields (Unique ID, First Name and
> Last Name). I have a SQL Server 2000 back-end with the table created
> as follows:
> UniqueID - numeric (9)
> FirstName - varchar (50)
> LastName - varchar (50)
> Ideally I would like the user just to enter their First and Last Name
> and the form automatically creates a Unique ID for them. Once they
> type in their First/Last Name the user submits the information to the
> database. I've managed to get the web form created so that it submits
> the First/Last Name successfully but I can't think how to create the
> Unique ID, ideally I'd like this to be based around the time/date of
> submittal.
> Any guidance would be much appreciated.
> Thanks
> Scott

Wednesday, March 28, 2012

Substitute Values in Column in Gridview

I have a Gridview bound to an SQLDataSource (see code below). The value of
the "DayOfWeek" column is actually an integer where 0 = Daily, 1=Sunday,
2=Monday, etc. How can I change what is displayed in the column from values
like 1or 2 to "Sunday", "Monday"?

============== Code =================
<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
AllowSorting="True"

AutoGenerateColumns="False" DataSourceID="SqlDataSource1"
<Columns
<asp:BoundField DataField="EventName" HeaderText="EventName"
SortExpression="EventName" /
<asp:BoundField DataField="DayOfWeek" HeaderText="DayOfWeek"
SortExpression="DayOfWeek" /
<asp:BoundField DataField="Occurs" HeaderText="Occurs"
SortExpression="Occurs" /
<asp:BoundField DataField="Location" HeaderText="Location"
SortExpression="Location" /
</Columns
</asp:GridViewI finally found an example that I could apply. I created a Select Case
function named GetDayOfWeek to return the string I wanted for each case and
then replaced the Bound Column in the ASP code to:

<asp:TemplateField HeaderText="Day of Week"
<ItemTemplate
<%#GetDayOfWeek(CInt(Eval("DayOfWeek")))%
</ItemTemplate
</asp:TemplateField
Wayne

"Wayne Wengert" <wayneSKIPSPAM@.wengert.org> wrote in message
news:ut%232Q9SRGHA.4696@.tk2msftngp13.phx.gbl...
>I have a Gridview bound to an SQLDataSource (see code below). The value of
>the "DayOfWeek" column is actually an integer where 0 = Daily, 1=Sunday,
>2=Monday, etc. How can I change what is displayed in the column from values
>like 1or 2 to "Sunday", "Monday"?
>
> ============== Code =================
> <asp:GridView ID="GridView1" runat="server" AllowPaging="True"
> AllowSorting="True"
> AutoGenerateColumns="False" DataSourceID="SqlDataSource1">
> <Columns>
> <asp:BoundField DataField="EventName" HeaderText="EventName"
> SortExpression="EventName" />
> <asp:BoundField DataField="DayOfWeek" HeaderText="DayOfWeek"
> SortExpression="DayOfWeek" />
> <asp:BoundField DataField="Occurs" HeaderText="Occurs"
> SortExpression="Occurs" />
> <asp:BoundField DataField="Location" HeaderText="Location"
> SortExpression="Location" />
> </Columns>
> </asp:GridView>

Subtract days from a Date

How can I code my app to get this date:

11/1/2203

From this date:

11/15/2003

I need to Subtract 14 days from 11/15/2003 but I am not sure to go about doing this.

ThanksThis may help

Dim dteNewDate As Date
Dim dteOldDate As Date = "01/01/03"
Dim intNoOfDays As Int16 = 11

dteNewDate = DateAdd("d", -intNoOfDays, dteOldDate)

TextBox1.Text = dteNewDate
The easiest way to do this is to pass a negative number into Date.AddDays(). I was able to perform the transformation you described using the following code:


Private Sub Calendar1_SelectionChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Calendar1.SelectionChanged
Label1.Text = Calendar1.SelectedDate.AddDays(-14)
End Sub

(This code should be run on a page with a Label and Calendar control if you want to try it out.)

Hope this helps.
<%
Dim dtmDate As DateTime
dtmDate = DateTime.Now()

Response.Write( dtmDate.ToString( "d" ) )

Dim AdddtmDate As DateTime

AdddtmDate = dtmDate.addDays(-14)

Response.write ("<br>")
Response.write (AdddtmDate)
%>
We recently wrote a simpletutorial example on working with Dates & Time in ASP.NET

Clay is right - just pass a negative number.

Bringing this back up. I found the information here very useful.

Can anyone tell me if there is a way to get what the last day of the month is? Like if the month is Febuary, I need to be able to detect 28 and 31 for March...


I don't think there is anything built in to get the last day of the month but you can use this little piece of code to get the last day of the month.

privateDateTime getLastDayOfMonth(DateTime d)

{

//get the first day of this month

int days = (d.Day - 1) * -1;

d = d.AddDays(days);

// add a month to this date

d = d.AddMonths(1);

d=d.AddDays(-1);

return d;

}

  

Subtracting from a Date

Hello,

In .NET code, I need to subtract a month from the current date; is there something in the framework that does this; there is some care that is needed to do this, especially with 28-day and 30-day months, so I was wondering if there was something built-in.

Thanks.

If I understand you question right you could do this:

DateTime dtTemp = DateTime.Now;

int Month = dtTemp.Month;

Cheers

Al


Dim dAs DateTime

d = DateTime.Now

d = d.AddMonths(-1)


If you write VB.NET try the link below for DateDiff function a clone of the T-SQL version. Hope this helps.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vblr7/html/vafctdatediff.asp


Hello,

Try it:

Dim LastMonth As Date = DateAdd(DateInterval.Month, -1, #3/27/2006#)

You'll found this function under following namespace:
Microsoft.VisualBasic

An this will solve your problem related to 28-days/30-days. Functions takes care of this.

Regards

Kuldeep Deokule

subtracting days from date

hI,
i AM TRYING TO SUBTRACT DAYS FROM PARTICULAR DATE. i KEEP GETTING THE ERROR:
hERE IS MY CODE: enddatecriteria=tempDate.AddDays(30);
startdatecriteria=tempDate.AddDays(-30);
I AM USING C# AND THE ERROR IS:
Ticks must be between DateTime.MinValue.Ticks and DateTime.MaxValue.Ticks.
Parameter name: ticks
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information abou
t
the error and where it originated in the code.
Exception Details: System.ArgumentOutOfRangeException: Ticks must be between
DateTime.MinValue.Ticks and DateTime.MaxValue.Ticks. Parameter name: ticks
Source Error:
cAN SOMEONE HELPtempDate = System.DateTime.Now;
enddatecriteria=tempDate.AddDays(30);
startdatecriteria=tempDate.AddDays(-30);
"Manny Chohan" wrote:

> hI,
> i AM TRYING TO SUBTRACT DAYS FROM PARTICULAR DATE. i KEEP GETTING THE ERRO
R:
> hERE IS MY CODE: enddatecriteria=tempDate.AddDays(30);
> startdatecriteria=tempDate.AddDays(-30);
> I AM USING C# AND THE ERROR IS:
> Ticks must be between DateTime.MinValue.Ticks and DateTime.MaxValue.Ticks.
> Parameter name: ticks
> Description: An unhandled exception occurred during the execution of the
> current web request. Please review the stack trace for more information ab
out
> the error and where it originated in the code.
> Exception Details: System.ArgumentOutOfRangeException: Ticks must be betwe
en
> DateTime.MinValue.Ticks and DateTime.MaxValue.Ticks. Parameter name: ticks
> Source Error:
> cAN SOMEONE HELP
my complete code is follows:
tempDate=Convert.ToDateTime(Calendar2.TodaysDate.ToShortDateString());
enddatecriteria=tempDate.AddDays(30);
startdatecriteria=tempDate.AddDays(-30);
It still give me error. I am using c#.
Thanks
Manny
"vinay" wrote:
> tempDate = System.DateTime.Now;
> enddatecriteria=tempDate.AddDays(30);
> startdatecriteria=tempDate.AddDays(-30);
>
> "Manny Chohan" wrote:
>
Which event are you checking the values'
post the full code.
"Manny Chohan" wrote:
> my complete code is follows:
> tempDate=Convert.ToDateTime(Calendar2.TodaysDate.ToShortDateString());
> enddatecriteria=tempDate.AddDays(30);
> startdatecriteria=tempDate.AddDays(-30);
> It still give me error. I am using c#.
> Thanks
> Manny
> "vinay" wrote:
>
thanks Vinay, here is the code:
if(!Page.IsPostBack)
{
Get_Appointments();
tempDate=Convert.ToDateTime(Calendar2.TodaysDate.ToShortDateString());
}
public void MonthChanged(object sender, MonthChangedEventArgs e)
{
//Set the tempDatevariable to the value in the MonthChangedEventArgs
NewDate property
tempDate = e.NewDate;
//Reload the collection
Get_Appointments();
}
ICollection Get_Appointments()
{
DateTime startDate = new DateTime(2004,11,1);
DateTime endDate = new DateTime(2004,12,1);
enddatecriteria=tempDate.AddDays(30);
startdatecriteria=tempDate.AddDays(-30);
Rest follows the custom code as i am working with vendor API. Please let me
know if this is enough.
Thanks
Manny
"vinay" wrote:
> Which event are you checking the values'
> post the full code.
> "Manny Chohan" wrote:
>
Manny, looks like your tempdate is empty when you do the startdatecriteria=
(you're trying to back off 30 days from what's already the date.minvalue).
I'd trace backwards from there and look at calendar2.todaysdate and
e.newdate. hth
"Manny Chohan" wrote:
> thanks Vinay, here is the code:
> if(!Page.IsPostBack)
> {
> Get_Appointments();
> tempDate=Convert.ToDateTime(Calendar2.TodaysDate.ToShortDateString()
);
> }
> public void MonthChanged(object sender, MonthChangedEventArgs e)
> {
> //Set the tempDatevariable to the value in the MonthChangedEventArgs
> NewDate property
> tempDate = e.NewDate;
> //Reload the collection
> Get_Appointments();
> }
> ICollection Get_Appointments()
> {
> DateTime startDate = new DateTime(2004,11,1);
> DateTime endDate = new DateTime(2004,12,1);
> enddatecriteria=tempDate.AddDays(30);
> startdatecriteria=tempDate.AddDays(-30);
> Rest follows the custom code as i am working with vendor API. Please let m
e
> know if this is enough.
> Thanks
> Manny
>
> "vinay" wrote:
>

subtracting days from date

hI,
i AM TRYING TO SUBTRACT DAYS FROM PARTICULAR DATE. i KEEP GETTING THE ERROR:
hERE IS MY CODE: enddatecriteria=tempDate.AddDays(30);
startdatecriteria=tempDate.AddDays(-30);
I AM USING C# AND THE ERROR IS:
Ticks must be between DateTime.MinValue.Ticks and DateTime.MaxValue.Ticks.
Parameter name: ticks
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.ArgumentOutOfRangeException: Ticks must be between
DateTime.MinValue.Ticks and DateTime.MaxValue.Ticks. Parameter name: ticks

Source Error:

cAN SOMEONE HELPtempDate = System.DateTime.Now;
enddatecriteria=tempDate.AddDays(30);
startdatecriteria=tempDate.AddDays(-30);

"Manny Chohan" wrote:

> hI,
> i AM TRYING TO SUBTRACT DAYS FROM PARTICULAR DATE. i KEEP GETTING THE ERROR:
> hERE IS MY CODE: enddatecriteria=tempDate.AddDays(30);
> startdatecriteria=tempDate.AddDays(-30);
> I AM USING C# AND THE ERROR IS:
> Ticks must be between DateTime.MinValue.Ticks and DateTime.MaxValue.Ticks.
> Parameter name: ticks
> 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.ArgumentOutOfRangeException: Ticks must be between
> DateTime.MinValue.Ticks and DateTime.MaxValue.Ticks. Parameter name: ticks
> Source Error:
> cAN SOMEONE HELP
my complete code is follows:
tempDate=Convert.ToDateTime(Calendar2.TodaysDate.T oShortDateString());

enddatecriteria=tempDate.AddDays(30);
startdatecriteria=tempDate.AddDays(-30);
It still give me error. I am using c#.
Thanks
Manny

"vinay" wrote:

> tempDate = System.DateTime.Now;
> enddatecriteria=tempDate.AddDays(30);
> startdatecriteria=tempDate.AddDays(-30);
>
> "Manny Chohan" wrote:
> > hI,
> > i AM TRYING TO SUBTRACT DAYS FROM PARTICULAR DATE. i KEEP GETTING THE ERROR:
> > hERE IS MY CODE: enddatecriteria=tempDate.AddDays(30);
> > startdatecriteria=tempDate.AddDays(-30);
> > I AM USING C# AND THE ERROR IS:
> > Ticks must be between DateTime.MinValue.Ticks and DateTime.MaxValue.Ticks.
> > Parameter name: ticks
> > 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.ArgumentOutOfRangeException: Ticks must be between
> > DateTime.MinValue.Ticks and DateTime.MaxValue.Ticks. Parameter name: ticks
> > Source Error:
> > cAN SOMEONE HELP
Which event are you checking the values??
post the full code.

"Manny Chohan" wrote:

> my complete code is follows:
> tempDate=Convert.ToDateTime(Calendar2.TodaysDate.T oShortDateString());
> enddatecriteria=tempDate.AddDays(30);
> startdatecriteria=tempDate.AddDays(-30);
> It still give me error. I am using c#.
> Thanks
> Manny
> "vinay" wrote:
> > tempDate = System.DateTime.Now;
> > enddatecriteria=tempDate.AddDays(30);
> > startdatecriteria=tempDate.AddDays(-30);
> > "Manny Chohan" wrote:
> > > hI,
> > > i AM TRYING TO SUBTRACT DAYS FROM PARTICULAR DATE. i KEEP GETTING THE ERROR:
> > > hERE IS MY CODE: enddatecriteria=tempDate.AddDays(30);
> > > startdatecriteria=tempDate.AddDays(-30);
> > > I AM USING C# AND THE ERROR IS:
> > > Ticks must be between DateTime.MinValue.Ticks and DateTime.MaxValue.Ticks.
> > > Parameter name: ticks
> > > 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.ArgumentOutOfRangeException: Ticks must be between
> > > DateTime.MinValue.Ticks and DateTime.MaxValue.Ticks. Parameter name: ticks
> > > > Source Error:
> > > > cAN SOMEONE HELP
thanks Vinay, here is the code:

if(!Page.IsPostBack)
{
Get_Appointments();
tempDate=Convert.ToDateTime(Calendar2.TodaysDate.T oShortDateString());

}
public void MonthChanged(object sender, MonthChangedEventArgs e)
{
//Set the tempDatevariable to the value in the MonthChangedEventArgs
NewDate property
tempDate = e.NewDate;
//Reload the collection
Get_Appointments();
}

ICollection Get_Appointments()
{

DateTime startDate = new DateTime(2004,11,1);
DateTime endDate = new DateTime(2004,12,1);

enddatecriteria=tempDate.AddDays(30);
startdatecriteria=tempDate.AddDays(-30);

Rest follows the custom code as i am working with vendor API. Please let me
know if this is enough.

Thanks

Manny

"vinay" wrote:

> Which event are you checking the values??
> post the full code.
> "Manny Chohan" wrote:
> > my complete code is follows:
> > tempDate=Convert.ToDateTime(Calendar2.TodaysDate.T oShortDateString());
> > enddatecriteria=tempDate.AddDays(30);
> > startdatecriteria=tempDate.AddDays(-30);
> > It still give me error. I am using c#.
> > Thanks
> > Manny
> > "vinay" wrote:
> > > tempDate = System.DateTime.Now;
> > > enddatecriteria=tempDate.AddDays(30);
> > > startdatecriteria=tempDate.AddDays(-30);
> > > > > "Manny Chohan" wrote:
> > > > > hI,
> > > > i AM TRYING TO SUBTRACT DAYS FROM PARTICULAR DATE. i KEEP GETTING THE ERROR:
> > > > hERE IS MY CODE: enddatecriteria=tempDate.AddDays(30);
> > > > startdatecriteria=tempDate.AddDays(-30);
> > > > I AM USING C# AND THE ERROR IS:
> > > > Ticks must be between DateTime.MinValue.Ticks and DateTime.MaxValue.Ticks.
> > > > Parameter name: ticks
> > > > 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.ArgumentOutOfRangeException: Ticks must be between
> > > > DateTime.MinValue.Ticks and DateTime.MaxValue.Ticks. Parameter name: ticks
> > > > > > Source Error:
> > > > > > cAN SOMEONE HELP
Manny, looks like your tempdate is empty when you do the startdatecriteria=
(you're trying to back off 30 days from what's already the date.minvalue).
I'd trace backwards from there and look at calendar2.todaysdate and
e.newdate. hth

"Manny Chohan" wrote:

> thanks Vinay, here is the code:
> if(!Page.IsPostBack)
> {
> Get_Appointments();
> tempDate=Convert.ToDateTime(Calendar2.TodaysDate.T oShortDateString());
> }
> public void MonthChanged(object sender, MonthChangedEventArgs e)
> {
> //Set the tempDatevariable to the value in the MonthChangedEventArgs
> NewDate property
> tempDate = e.NewDate;
> //Reload the collection
> Get_Appointments();
> }
> ICollection Get_Appointments()
> {
> DateTime startDate = new DateTime(2004,11,1);
> DateTime endDate = new DateTime(2004,12,1);
> enddatecriteria=tempDate.AddDays(30);
> startdatecriteria=tempDate.AddDays(-30);
> Rest follows the custom code as i am working with vendor API. Please let me
> know if this is enough.
> Thanks
> Manny
>
> "vinay" wrote:
> > Which event are you checking the values??
> > post the full code.
> > "Manny Chohan" wrote:
> > > my complete code is follows:
> > > tempDate=Convert.ToDateTime(Calendar2.TodaysDate.T oShortDateString());
> > > > enddatecriteria=tempDate.AddDays(30);
> > > startdatecriteria=tempDate.AddDays(-30);
> > > It still give me error. I am using c#.
> > > Thanks
> > > Manny
> > > > "vinay" wrote:
> > > > > tempDate = System.DateTime.Now;
> > > > enddatecriteria=tempDate.AddDays(30);
> > > > startdatecriteria=tempDate.AddDays(-30);
> > > > > > > > "Manny Chohan" wrote:
> > > > > > > hI,
> > > > > i AM TRYING TO SUBTRACT DAYS FROM PARTICULAR DATE. i KEEP GETTING THE ERROR:
> > > > > hERE IS MY CODE: enddatecriteria=tempDate.AddDays(30);
> > > > > startdatecriteria=tempDate.AddDays(-30);
> > > > > I AM USING C# AND THE ERROR IS:
> > > > > Ticks must be between DateTime.MinValue.Ticks and DateTime.MaxValue.Ticks.
> > > > > Parameter name: ticks
> > > > > 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.ArgumentOutOfRangeException: Ticks must be between
> > > > > DateTime.MinValue.Ticks and DateTime.MaxValue.Ticks. Parameter name: ticks
> > > > > > > > Source Error:
> > > > > > > > cAN SOMEONE HELP

Monday, March 26, 2012

suggestion for improvement

hey all,
in regards to the visual studio code editor (for any language), and in
additon to auto outlining it would be nice if we could hide our own lines of
code at the same time.
i know you can say stop auto outlining and then do the hiding but doing both
would be great and in addition to that to somehow persist the custom
outlining.
hope i haven't went overboard.
thanks,
rodcharrodchar,
The Product Feedback Site is the place. You can also search it to see if
anyone else has made a similar suggestion, and you can track the results of
your input.
Cheers,
Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net
"rodchar" wrote:

> hey all,
> in regards to the visual studio code editor (for any language), and in
> additon to auto outlining it would be nice if we could hide our own lines
of
> code at the same time.
> i know you can say stop auto outlining and then do the hiding but doing bo
th
> would be great and in addition to that to somehow persist the custom
> outlining.
> hope i haven't went overboard.
> thanks,
> rodchar

suggestion for improvement

hey all,
in regards to the visual studio code editor (for any language), and in
additon to auto outlining it would be nice if we could hide our own lines of
code at the same time.

i know you can say stop auto outlining and then do the hiding but doing both
would be great and in addition to that to somehow persist the custom
outlining.

hope i haven't went overboard.

thanks,
rodcharrodchar,
The Product Feedback Site is the place. You can also search it to see if
anyone else has made a similar suggestion, and you can track the results of
your input.
Cheers,
Peter

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net
"rodchar" wrote:

Quote:

Originally Posted by

hey all,
in regards to the visual studio code editor (for any language), and in
additon to auto outlining it would be nice if we could hide our own lines of
code at the same time.
>
i know you can say stop auto outlining and then do the hiding but doing both
would be great and in addition to that to somehow persist the custom
outlining.
>
hope i haven't went overboard.
>
thanks,
rodchar

Suggestion on code sample for daily.weekly.monthly calendar

I would like to make a calendar that can be use to enter appointments, in a hour basis, and i will look to have a day, weekly and monthly view, could you suggest a online sample code ?

Hi!

You should have a look at this:http://www.codeproject.com/aspnet/daypilot.asp

Suggestions for "For ... Next"

Hi,

I never used the For...Next Statement.

Can someone give me some suggestions how i can use it with this code to simplify it

Thanks in advance
------------------

If TotalPagesInteger < 8 Then
If TotalPagesInteger = 1 Then
LinkPage_1.Visible = True
LinkPage_1.Text = "1"
ElseIf TotalPagesInteger = 2 Then
LinkPage_1.Visible = True
LinkPage_2.Visible = True
LinkPage_1.Text = "1"
LinkPage_2.Text = "2"
ElseIf TotalPagesInteger = 3 Then
LinkPage_1.Visible = True
LinkPage_2.Visible = True
LinkPage_3.Visible = True
LinkPage_1.Text = "1"
LinkPage_2.Text = "2"
LinkPage_3.Text = "3"
ElseIf TotalPagesInteger = 4 Then
LinkPage_1.Visible = True
LinkPage_2.Visible = True
LinkPage_3.Visible = True
LinkPage_4.Visible = True
LinkPage_1.Text = "1"
LinkPage_2.Text = "2"
LinkPage_3.Text = "3"
LinkPage_4.Text = "4"
ElseIf TotalPagesInteger = 5 Then
LinkPage_1.Visible = True
LinkPage_2.Visible = True
LinkPage_3.Visible = True
LinkPage_4.Visible = True
LinkPage_5.Visible = True
LinkPage_1.Text = "1"
LinkPage_2.Text = "2"
LinkPage_3.Text = "3"
LinkPage_4.Text = "4"
LinkPage_5.Text = "5"
ElseIf TotalPagesInteger = 6 Then
LinkPage_1.Visible = True
LinkPage_2.Visible = True
LinkPage_3.Visible = True
LinkPage_4.Visible = True
LinkPage_5.Visible = True
LinkPage_6.Visible = True
LinkPage_1.Text = "1"
LinkPage_2.Text = "2"
LinkPage_3.Text = "3"
LinkPage_4.Text = "4"
LinkPage_5.Text = "5"
LinkPage_6.Text = "6"
ElseIf TotalPagesInteger = 7 Then
LinkPage_1.Visible = True
LinkPage_2.Visible = True
LinkPage_3.Visible = True
LinkPage_4.Visible = True
LinkPage_5.Visible = True
LinkPage_6.Visible = True
LinkPage_7.Visible = True
LinkPage_1.Text = "1"
LinkPage_2.Text = "2"
LinkPage_3.Text = "3"
LinkPage_4.Text = "4"
LinkPage_5.Text = "5"
LinkPage_6.Text = "6"
LinkPage_7.Text = "7"
End If
End If

Hi, I think I'd use a Select Case statement for this. Something like:

Select Case TotalPagesInteger
Case 1
LinkPage_1.Visible =True
LinkPage_1.Text ="1"
Case 2
LinkPage_1.Visible =True
LinkPage_2.Visible =True
LinkPage_1.Text ="1"
LinkPage_2.Text ="2"
Case 3
LinkPage_1.Visible =True
LinkPage_2.Visible =True
LinkPage_3.Visible =True
LinkPage_1.Text ="1"
LinkPage_2.Text ="2"
LinkPage_3.Text ="3"
Case 4
... more code
End Select


Hello my friend,

Use the following: -

If TotalPagesInteger < 8 Then
For i As Integer = 1 To 7
If i <= TotalPagesInteger Then
Dim lnk As HyperLink = DirectCast(Me.FindControl("LinkPage_" & i), HyperLink)
lnk.Visible = True
lnk.Text = i
End If
Next
End If


I assumed that LinkPage_1, LinkPage_2, etc are hyperlinks. If not, just change HyperLink in the code to whatever the controls are.


Kind regards

Scotty


Humm,

I tried it and it gives me this error :

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.

Source Error:

Line 231: If i <= TotalPagesInteger ThenLine 232: Dim lnk As HyperLink = DirectCast(Me.FindControl("LinkPage_" & i), HyperLink)Line 233: lnk.Visible = TrueLine 234: lnk.Text = iLine 235: End If


Hi,

This error message tells you, it could not find control of LinkPage_1(or LinkPage_2, LinkPage_3 etc.) in the page, you should check whether there are the LinkPages' id in the page.


Im sure that is theDirectCast that is wrong.

Can somebody help?


This should help you out. I think that this is what you are looking for.

Dim outIdx as Integer

If TotalPagesInteger < 8 Then
For outIdx = 1 to TotalPagesInteger
Dim hlink As HyperLink = DirectCast(Me.FindControl("LinkPage_" & outIdx), HyperLink)
hlink.Visible = True
hlink.Text = inIdx.ToString
Next
End If

Basically you are wanting to go from 1 to the TotalPagesInteger and make all the previous links visible and the text to be the number of the page.

Ben Miller


Nope

Didn't work too!

I got the same error and LinkPage_1 to LinkPage_7 exists in my code...

Any idea?


I am totally sorry. I got sidetracked using the FindControl. This only works if they are rendered on the page, so I went back to look at your coding and I now understand what you want.

You could so something like this then to take advantage of the For loop.

Dim aryList as ArrayList = new ArrayList()

aryList.Add(LinkPage_1)
aryList.Add(LinkPage_2)
aryList.Add(LinkPage_3)
aryList.Add(LinkPage_4)
aryList.Add(LinkPage_5)
aryList.Add(LinkPage_6)
aryList.Add(LinkPage_7)

Dim outIdx as Integer

If TotalPagesInteger < 8 Then
For outIdx = 1 to TotalPagesInteger
Dim hlink As HyperLink = DirectCast(aryList[outIdx-1], HyperLink)
hlink.Visible = True
hlink.Text = inIdx.ToString
Next
End If

That should do it. Sorry for the delay.

Ben Miller


Hi,

Thanks!!!

Here is the working code :
------------
Dim aryList As ArrayList = New ArrayList()
aryList.Add(LinkPage_1)
aryList.Add(LinkPage_2)
aryList.Add(LinkPage_3)
aryList.Add(LinkPage_4)
aryList.Add(LinkPage_5)
aryList.Add(LinkPage_6)
aryList.Add(LinkPage_7)

Dim outIdx As Integer
Dim hlink As HyperLink

If TotalPagesInteger < 8 Then
For outIdx = 1 To TotalPagesInteger
hlink = DirectCast(aryList(outIdx - 1), HyperLink)
hlink.Visible = True
hlink.Text = outIdx.ToString
Next
End If

Saturday, March 24, 2012

Sum of XML data

I am reading an XML file and writing its contents to a Repeater control using the following code:

Dim dstTS As DataSet

dstTS = New DataSet()
dstTS.ReadXml( MapPath( "cw052004.xml" ) )

rptTS.DataSource = dstTS
rptTS.DataBind()

It works fine. However, I would also like to calculate the sum of a the "item_cost" from each node in the XML file and place it in a variable.

Can anybody suggest the best way to go about this?do some searching for examples on the itemdatabound event. this is fired everytime an item is bound and you can use this to sum up your grids and such.
Awesome, thanks!

Thursday, March 22, 2012

Support for generating random passwords in ASP.NET

Hi,
I am building web in ASP.NET using VB.NET to code the pages. I want to gene
rate random passwords for users. I know that password hashing is built right
into the .NET Framework. I was wondering if there is any built-in support f
or generating random passwo
rds in .Net. If the support is built-in, can you show me how to do it.
Thanks,
JoeThere is no random password functionality built into .NET.
But there is the Math.Random namespace that could easily help you string
together some random characters.
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"Joe" <Joe@.discussions.microsoft.com> wrote in message
news:C6413BC5-1DF5-4C8D-ADC2-BCEB6BBAB5F8@.microsoft.com...
> Hi,
> I am building web in ASP.NET using VB.NET to code the pages. I want to
generate random passwords for users. I know that password hashing is built
right into the .NET Framework. I was wondering if there is any built-in
support for generating random passwords in .Net. If the support is
built-in, can you show me how to do it.
> Thanks,
> Joe
>
Joe
Try this.. http://www.4guysfromrolla.com/webte...t011100-1.shtml
It's ASP rather than .NET, but shouldn't take too much conversion.
HTH
Dan
"Joe" wrote:

> Hi,
> I am building web in ASP.NET using VB.NET to code the pages. I want to generate r
andom passwords for users. I know that password hashing is built right into the .NET
Framework. I was wondering if there is any built-in support for generating random p
ass
words in .Net. If the support is built-in, can you show me how to do it.
> Thanks,
> Joe
>

Support for generating random passwords in ASP.NET

Hi,

I am building web in ASP.NET using VB.NET to code the pages. I want to generate random passwords for users. I know that password hashing is built right into the .NET Framework. I was wondering if there is any built-in support for generating random passwords in .Net. If the support is built-in, can you show me how to do it.

Thanks,

JoeThere is no random password functionality built into .NET.
But there is the Math.Random namespace that could easily help you string
together some random characters.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net

"Joe" <Joe@.discussions.microsoft.com> wrote in message
news:C6413BC5-1DF5-4C8D-ADC2-BCEB6BBAB5F8@.microsoft.com...
> Hi,
> I am building web in ASP.NET using VB.NET to code the pages. I want to
generate random passwords for users. I know that password hashing is built
right into the .NET Framework. I was wondering if there is any built-in
support for generating random passwords in .Net. If the support is
built-in, can you show me how to do it.
> Thanks,
> Joe
Joe

Try this.. http://www.4guysfromrolla.com/webte...t011100-1.shtml

It's ASP rather than .NET, but shouldn't take too much conversion.

HTH

Dan

"Joe" wrote:

> Hi,
> I am building web in ASP.NET using VB.NET to code the pages. I want to generate random passwords for users. I know that password hashing is built right into the .NET Framework. I was wondering if there is any built-in support for generating random passwords in .Net. If the support is built-in, can you show me how to do it.
> Thanks,
> Joe

Supporting Languages - Welsh ?

How do I add the Welsh language to IE6 ?

And what would the ISO code be for it ?

I've tried using the User Defined cy as some sites say, but the following
code just uses the catch block as it's not found.

Try
Thread.CurrentThread.CurrentCulture =
CultureInfo.CreateSpecificCulture(Request.UserLang uages(0))
ls_language = Thread.CurrentThread.CurrentCulture.Name
Catch
Thread.CurrentThread.CurrentCulture =
CultureInfo.CreateSpecificCulture("en-gb")
ls_language = Thread.CurrentThread.CurrentCulture.Name
End Try
HttpContext.Current.Response.Cookies.Add(New HttpCookie("Cul", ls_language))

--
Adrian Parker
Ingenuity At Work LtdHi Adrian,

Welcome to the MSDN newsgroup.

As for the "Welsh", it is still not included in the .net framework (both
1.1 and 2.0)'s predefined cultureInfo list:

#CultureInfo Class
http://msdn2.microsoft.com/en-us/li...cultureinfo.as
px

So even if we add a custom language header(for Welsh) in the http message
through IE's languages setting, the server-side ASP.NET application can not
find the direct mapped culture for it.

BTW, currently for windows XP(>SP2), if you're using .net framework 2.0,
there is a "Welsh" culture available in the OS's regional setting. And in
the .net framework 2.0 code, we can use the "cy-GB" to create the
CultureInfo specific to that setting.'

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Hi Steven,

So if we use cy-GB as our language, it would work, but only using net2.0 on XPsp2 ?

Is this currently supported on windows 2003 ? and if not now, when will it be ?

Thanks
--
Adrian Parker
Ingenuity At Work Ltd

"Steven Cheng[MSFT]" <stcheng@.online.microsoft.com> wrote in message news:%23QOiBxPPGHA.2972@.TK2MSFTNGXA03.phx.gbl...
> Hi Adrian,
> Welcome to the MSDN newsgroup.
> As for the "Welsh", it is still not included in the .net framework (both
> 1.1 and 2.0)'s predefined cultureInfo list:
> #CultureInfo Class
> http://msdn2.microsoft.com/en-us/li...cultureinfo.as
> px
> So even if we add a custom language header(for Welsh) in the http message
> through IE's languages setting, the server-side ASP.NET application can not
> find the direct mapped culture for it.
> BTW, currently for windows XP(>SP2), if you're using .net framework 2.0,
> there is a "Welsh" culture available in the OS's regional setting. And in
> the .net framework 2.0 code, we can use the "cy-GB" to create the
> CultureInfo specific to that setting.'
> Regards,
> Steven Cheng
> Microsoft Online Support
> Get Secure! www.microsoft.com/security
> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)
Thanks for your response Adrian,

So far it is limited on other OS version and I haven't got any definite
info on when it'll also be upgrated to windows 2k3. However, for .net
framework 2.0, it doest provide some new features on extending the exiting
culture set regarding on the lack of some built-in or predefined culture in
framework or on windows OS.

#Extend Your Code's Global Reach With New Features In The .NET Framework 2.0
http://msdn.microsoft.com/msdnmag/i...on/default.aspx

Though it is still quite limited, we can use it to do handle some
additional conditions in .net 2.0 applications.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Supporting Languages - Welsh ?

How do I add the Welsh language to IE6 ?
And what would the ISO code be for it ?
I've tried using the User Defined cy as some sites say, but the following
code just uses the catch block as it's not found.
Try
Thread.CurrentThread.CurrentCulture =
CultureInfo.CreateSpecificCulture(Request.UserLanguages(0))
ls_language = Thread.CurrentThread.CurrentCulture.Name
Catch
Thread.CurrentThread.CurrentCulture =
CultureInfo.CreateSpecificCulture("en-gb")
ls_language = Thread.CurrentThread.CurrentCulture.Name
End Try
HttpContext.Current.Response.Cookies.Add(New HttpCookie("Cul", ls_language))
Adrian Parker
Ingenuity At Work LtdHi Adrian,
Welcome to the MSDN newsgroup.
As for the "Welsh", it is still not included in the .net framework (both
1.1 and 2.0)'s predefined cultureInfo list:
#CultureInfo Class
http://msdn2.microsoft.com/en-us/li...cultureinfo.as
px
So even if we add a custom language header(for Welsh) in the http message
through IE's languages setting, the server-side ASP.NET application can not
find the direct mapped culture for it.
BTW, currently for windows XP(>SP2), if you're using .net framework 2.0,
there is a "Welsh" culture available in the OS's regional setting. And in
the .net framework 2.0 code, we can use the "cy-GB" to create the
CultureInfo specific to that setting.'
Regards,
Steven Cheng
Microsoft Online Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Hi Steven,
So if we use cy-GB as our language, it would work, but only using net2.0 on
XPsp2 ?
Is this currently supported on windows 2003 ? and if not now, when will it b
e ?
Thanks
--
Adrian Parker
Ingenuity At Work Ltd
"Steven Cheng[MSFT]" <stcheng@.online.microsoft.com> wrote in message news:%23QOiBxPPGHA.2972@.TK2M
SFTNGXA03.phx.gbl...
> Hi Adrian,
> Welcome to the MSDN newsgroup.
> As for the "Welsh", it is still not included in the .net framework (both
> 1.1 and 2.0)'s predefined cultureInfo list:
> #CultureInfo Class
> [url]http://msdn2.microsoft.com/en-us/library/system.globalization.cultureinfo.as[/ur
l]
> px
> So even if we add a custom language header(for Welsh) in the http message
> through IE's languages setting, the server-side ASP.NET application can no
t
> find the direct mapped culture for it.
> BTW, currently for windows XP(>SP2), if you're using .net framework 2.0,
> there is a "Welsh" culture available in the OS's regional setting. And in
> the .net framework 2.0 code, we can use the "cy-GB" to create the
> CultureInfo specific to that setting.'
> Regards,
> Steven Cheng
> Microsoft Online Support
> Get Secure! www.microsoft.com/security
> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)
>
>
Thanks for your response Adrian,
So far it is limited on other OS version and I haven't got any definite
info on when it'll also be upgrated to windows 2k3. However, for .net
framework 2.0, it doest provide some new features on extending the exiting
culture set regarding on the lack of some built-in or predefined culture in
framework or on windows OS.
#Extend Your Code's Global Reach With New Features In The .NET Framework 2.0
http://msdn.microsoft.com/msdnmag/i...on/default.aspx
Though it is still quite limited, we can use it to do handle some
additional conditions in .net 2.0 applications.
Regards,
Steven Cheng
Microsoft Online Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Suppress Crystal Reports Section in VB .Net 2003

Hello everyone. When I had VS .Net 2002, I could use the following code to suppress a section in my crystal report.crpt.Section6.SectionFormat.EnableSuppress = True
Now that I have moved to plain VB .Net 2003 with Crystal Reports 10, this command will not work.

Anyone know the correct syntax for this line in VB .Net for Crystal 10?

Here is my initial code in my web page.
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports System.IO

Dim crpt As New ReportDocument

crpt.Load("C:\inetpub\wwwroot\McClure\CigUnitsRpt.rpt")

ThanksBump
For anyone interested, this is the way to do it with VB .Net 2003 and Crystal 10
dim crpt as New ReortDocument()
crpt.Load("PathAndFileName")
crpt.ReportDefinition.Sections(6).SectionFormat.EnableSuppress = True

Suppress Masterpage

hi,
I am looking into reusing code to limit number of pages.
When ever I display a user's name on the site, It is with a hyperlink so you
can view the user profile in a popup window.
Is there a way to suppress the masterpage when a page is shown in my popup
windows?
JonasSure, just don't specify a master page for the popup window.
In the page header, don't add a MasterPageFile attribute.
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
"Jonas Pedersen" <qwert@.qwerty.com> wrote in message
news:O$vof7RJIHA.484@.TK2MSFTNGP06.phx.gbl...
> hi,
> I am looking into reusing code to limit number of pages.
> When ever I display a user's name on the site, It is with a hyperlink so
> you can view the user profile in a popup window.
> Is there a way to suppress the masterpage when a page is shown in my popup
> windows?
> Jonas
>

Suppress Masterpage

hi,

I am looking into reusing code to limit number of pages.
When ever I display a user's name on the site, It is with a hyperlink so you
can view the user profile in a popup window.
Is there a way to suppress the masterpage when a page is shown in my popup
windows?

JonasSure, just don't specify a master page for the popup window.

In the page header, don't add a MasterPageFile attribute.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
"Jonas Pedersen" <qwert@.qwerty.comwrote in message
news:O$vof7RJIHA.484@.TK2MSFTNGP06.phx.gbl...

Quote:

Originally Posted by

hi,
>
I am looking into reusing code to limit number of pages.
When ever I display a user's name on the site, It is with a hyperlink so
you can view the user profile in a popup window.
Is there a way to suppress the masterpage when a page is shown in my popup
windows?
>
Jonas
>