Showing posts with label ide. Show all posts
Showing posts with label ide. Show all posts

Thursday, March 29, 2012

Newbie: I need some tips

IDE vs .NET 2003
OS: XP pro sp2

I need to create a asp.net page which will receive data sent to it via
GET... The data sent into the page is a number, this number should be added
together with the numbers sent into the page by other users...

for example:
user A: http://localhost/test.aspx?value=1
and
user B: http://localhost/test.aspx?value=2

if user C want to retrieve this value, he should get the value 3 (1 +2)

Here som of the code in my Global.asax.cs:
public class Global : System.Web.HttpApplication
{
/// <summary>
/// Required designer variable.
/// </summary>
///
int b;

protected void Application_Start(Object sender, EventArgs e)
{
b ++;
Application.Add("test", b);
}

As you can see from my code above, I'm trying to fix this problem using
HttpApplication... Is that the correct approach? If it isn't, what is the
correct approach then??

JeffUsing Application is fine...but you should be putting it in the
Application_BeginRequest method, or the Page_Load of test.
Application_Start fires once and only once so it'll never add. It's hard to
advise without knowing more in detail. I'd be tempted to scoping this out
to the test.aspx page.

The following code will in no way compile, but should give you a general
idea

page_load
int userInput;
try{
userInput = Int32.Parse(Request.QueryString["value"]);
}catch (Exception ex){
if (!(ex is FormatException) && !(ex is InvalidCastException) && !(ex
is OverflowException))
throw;
}
object o = Application["totalCount"]
if (Application["totalCount"] != null){
((int)Application["totalCount"]) += userInput
}else{
Application["totalCount"] = userInput;
}

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)

"Jeff" <it_consultant1@.hotmail.com.NOSPAM> wrote in message
news:%23KAabkfWFHA.3716@.TK2MSFTNGP12.phx.gbl...
> IDE vs .NET 2003
> OS: XP pro sp2
> I need to create a asp.net page which will receive data sent to it via
> GET... The data sent into the page is a number, this number should be
> added
> together with the numbers sent into the page by other users...
> for example:
> user A: http://localhost/test.aspx?value=1
> and
> user B: http://localhost/test.aspx?value=2
> if user C want to retrieve this value, he should get the value 3 (1 +2)
> Here som of the code in my Global.asax.cs:
> public class Global : System.Web.HttpApplication
> {
> /// <summary>
> /// Required designer variable.
> /// </summary>
> ///
> int b;
> protected void Application_Start(Object sender, EventArgs e)
> {
> b ++;
> Application.Add("test", b);
> }
> As you can see from my code above, I'm trying to fix this problem using
> HttpApplication... Is that the correct approach? If it isn't, what is the
> correct approach then??
> Jeff

Newbie: I need some tips

IDE vs .NET 2003
OS: XP pro sp2
I need to create a asp.net page which will receive data sent to it via
GET... The data sent into the page is a number, this number should be added
together with the numbers sent into the page by other users...
for example:
user A: http://localhost/test.aspx?value=1
and
user B: http://localhost/test.aspx?value=2
if user C want to retrieve this value, he should get the value 3 (1 +2)
Here som of the code in my Global.asax.cs:
public class Global : System.Web.HttpApplication
{
/// <summary>
/// Required designer variable.
/// </summary>
///
int b;
protected void Application_Start(Object sender, EventArgs e)
{
b ++;
Application.Add("test", b);
}
As you can see from my code above, I'm trying to fix this problem using
HttpApplication... Is that the correct approach? If it isn't, what is the
correct approach then'
JeffUsing Application is fine...but you should be putting it in the
Application_BeginRequest method, or the Page_Load of test.
Application_Start fires once and only once so it'll never add. It's hard to
advise without knowing more in detail. I'd be tempted to scoping this out
to the test.aspx page.
The following code will in no way compile, but should give you a general
idea
page_load
int userInput;
try{
userInput = Int32.Parse(Request.QueryString["value"]);
}catch (Exception ex){
if (!(ex is FormatException) && !(ex is InvalidCastException) && !(ex
is OverflowException))
throw;
}
object o = Application["totalCount"]
if (Application["totalCount"] != null){
((int)Application["totalCount"]) += userInput
}else{
Application["totalCount"] = userInput;
}
Karl
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Jeff" <it_consultant1@.hotmail.com.NOSPAM> wrote in message
news:%23KAabkfWFHA.3716@.TK2MSFTNGP12.phx.gbl...
> IDE vs .NET 2003
> OS: XP pro sp2
> I need to create a asp.net page which will receive data sent to it via
> GET... The data sent into the page is a number, this number should be
> added
> together with the numbers sent into the page by other users...
> for example:
> user A: http://localhost/test.aspx?value=1
> and
> user B: http://localhost/test.aspx?value=2
> if user C want to retrieve this value, he should get the value 3 (1 +2)
> Here som of the code in my Global.asax.cs:
> public class Global : System.Web.HttpApplication
> {
> /// <summary>
> /// Required designer variable.
> /// </summary>
> ///
> int b;
> protected void Application_Start(Object sender, EventArgs e)
> {
> b ++;
> Application.Add("test", b);
> }
> As you can see from my code above, I'm trying to fix this problem using
> HttpApplication... Is that the correct approach? If it isn't, what is the
> correct approach then'
> Jeff
>
>

Saturday, March 24, 2012

newbie: Table position

Hi,

Using the IDE, I create a nested table within another. I set its position by
setting the style to Absolutely, but when I set it back to normal flow, it
doesn't return to the top left of the cell in which it is nested as would be
expected. So I changed the style position to "Not Set" but the nested table
refuses to return to the top left.

There is no padding set.

Is this some known issue? Am I doing something wrong?

Any suggestions would be a great help

Many thanks in advance
antOn Oct 6, 4:58 am, Ant <A...@.discussions.microsoft.comwrote:

Quote:

Originally Posted by

Hi,
>
Using the IDE, I create a nested table within another. I set its position by
setting the style to Absolutely, but when I set it back to normal flow, it
doesn't return to the top left of the cell in which it is nested as would be
expected. So I changed the style position to "Not Set" but the nested table
refuses to return to the top left.
>
There is no padding set.
>
Is this some known issue? Am I doing something wrong?
>
Any suggestions would be a great help
>
Many thanks in advance
ant


Switch to the html mode and check what code do you have in the cell.

Thursday, March 22, 2012

newbie--datalist question

I have the ASP Unleased book--of course all code. So it doesn't help me tie
it to the VSNET IDE easily--to know what I have to do and what is done for
me.

I am trying to make a simple datalist that will get 3 fields from a database
plus the Identity field--so 4 total--identity field won't be shown.

I dropped a datalist on the webform.. Found the Edit Template menu
item...went into edit template mode..
I dragged some Web forms controls in each of the various templates. I set
style background colors etc.

In this design form all three controls (webform labels) are on one line, but
the show up with a large amount of space between each item (vertically)
Why?
I do have an edititem template that is larger and has multiple lines, but I
thought that that only mattered when it was to do an edit.

I made a linkbutton Edit in the ItemTemplate

I set its commandname to edit

in my book he had to do a OnEditCommand=dlstAuthors_EditCommand in his
example...
with the IDE, I don't have to do that or do I.

I am connecting to SQL in code not through a sqlconnection control--does
that matter?

Due to this I had to go into my HTML code and place the text='<%#
container.dataitem("whatever")%>
Manually. Should I have done it this way... Is there a way to do that in
the IDE? Or will it only work if there is a SQL Connection control on the
form? What is the best way?

Anyhow in the datalist1_editcommand sub
I placed
datalist1.edititemindex=e.item.itemindex
binddatalist 'this just hits the sql server for the data

But click edit didn't bring up the edit item as I had imagined.

Can anyone tell me why my formatting for each item has all this vertical
space between items, but in the template I see no reason why?

And why doesn't my edit command work?

ThanksSStory,

>In this design form all three controls (webform labels) >are on one
line, but
>the show up with a large amount of space between each item
>(vertically)
>Why?

You should look at the HTML to figure out the formatting.

>in my book he had to do a >OnEditCommand=dlstAuthors_EditCommand in his
>example...
>with the IDE, I don't have to do that or do I.

Contrary to the opening pages of any beginner book, the drag'n'drop
features of the IDE will not take you very far. The
OnEditCommand=dlsAuthor_EditCommand is what associates Edit clicks
within the DataList with an event handler, in this case Sub
dlsAuthors_EditCommand (bottom of page 539).

The SQLConnection control on the form is a simple way to have the IDE
write some of you code for you. There are a bunch of different ways to
connect to a db. Whatever works, works.

To make the edit work, you have to have CommandName="edit" in the
control, "OnEditCommand = dlsAuthor_EditCommand" in the DataList, and
"datalist1.edititemindex=e.item.itemindex" within the sub routine,
making sure that the datalist1 value is the same as the name of your
datalist (dlstAuthors in the book).

I hope this helps,
Barry

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Thanks for the answers Barry.

So this means if I had placed a SQL connection on the form it would have done this for me, but since I connected by code I have to do the On command statements in HTML..

Here's the code(on down below).. Why does it space so far apart between each item ( I added the pre tags to show the code in html emailer)?

what I want for example is

Edit Nashville, TN 30105
Edit Camden, AL 30306
should be simple

Then the edit form would be bigger like
City [text box]

State [drop down]

Zip [text box]
Update Delete Cancel

Any how it looks more like
Edit Nashville, TN 30105

Edit Camden, AL 30306
<pre> <asp:datalist id="dlstRepAvailLocations" runat="server" height="124px">
<selecteditemtemplate>
<asp:label id="Label20" runat="server" width="76px" text='<%# Container.dataitem("rploc_City")%>'>
</asp:label>,
<asp:label id="Label21" runat="server" width="33px" text='<%# Container.dataitem("rploc_State")%>'>
</asp:label>
<asp:label id="Label22" runat="server" text='<%# Container.dataitem("rploc_ZipCode")%>'>
</asp:label>
</selecteditemtemplate>
<itemtemplate>
<asp:linkbutton id="lnkEdit" runat="server" commandname="edit">Edit</asp:linkbutton>
<asp:label id="lblDLCity" runat="server" width="76px" text='<%# Container.dataitem("rploc_City")%>'>
</asp:label>,
<asp:label id="lblDLState" runat="server" width="33px" text='<%# Container.dataitem("rploc_State")%>'>
</asp:label>
<asp:label id="lblDLZipCode" runat="server" text='<%# Container.dataitem("rploc_Zipcode")%>'>
</asp:label>
</itemtemplate>
<alternatingitemtemplate>
<asp:linkbutton id="lnkEditAlt" runat="server" commandname="edit">Edit</asp:linkbutton>
<asp:label id="Label17" runat="server" width="76px" text='<%# Container.dataitem("rploc_City")%>'>
</asp:label>,
<asp:label id="Label18" runat="server" width="33px" text='<%# Container.dataitem("rploc_State")%>'>
</asp:label>
<asp:label id="Label19" runat="server" text='<%# Container.dataitem("rploc_ZipCode")%>'>
</asp:label>
</alternatingitemtemplate>
<edititemtemplate>
<p>
<asp:label id="Label23" runat="server" width="68">City</asp:label>
<asp:textbox id="txtEditCity" runat="server" width="115px" text='<%# Container.dataitem("rploc_City")%>'>
</asp:textbox>
<asp:requiredfieldvalidator id="Requiredfieldvalidator1" runat="server" cssclass="VALERRMSG" errormessage="City Required"></asp:requiredfieldvalidator><br>
<asp:label id="Label24" runat="server" width="69">State</asp:label>
<uc1:states id="States1" runat="server"></uc1:states><br>
<asp:label id="Label25" runat="server" width="69px">Zip Code</asp:label>
<asp:textbox id="txtEditZipCode" runat="server" width="70px" text='<%# Container.dataitem("rploc_City")%>'>
</asp:textbox>
<asp:requiredfieldvalidator id="Requiredfieldvalidator5" runat="server" cssclass="VALERRMSG" errormessage="Zip Code Required"></asp:requiredfieldvalidator></p>
<p align="center">
<asp:linkbutton id="lnkUpdate" runat="server" commandname="update">LinkButton</asp:linkbutton> |
<asp:linkbutton id="lnkDelete" runat="server" commandname="delete">Delete</asp:linkbutton> |
<asp:linkbutton id="lnkCancel" runat="server" commandname="cancel">Cancel</asp:linkbutton></p>
</edititemtemplate>
</asp:datalist></pre
At first I was using grid layout but then switched and threw this datalist into a table cell on the left side.
I have project I need to do within a month--pretty big--I really need to figure this and datagrids out.
Probably work similar.

Thanks in Advance,

Shane

"Barry" <barrygilbert@.nospam.com> wrote in message news:#fbLnD5WDHA.1940@.TK2MSFTNGP10.phx.gbl...
> SStory,
>
> >In this design form all three controls (webform labels) >are on one
> line, but
> >the show up with a large amount of space between each item
> >(vertically)
> >Why?
>
> You should look at the HTML to figure out the formatting.
>
> >in my book he had to do a >OnEditCommand=dlstAuthors_EditCommand in his
> >example...
> >with the IDE, I don't have to do that or do I.
>
> Contrary to the opening pages of any beginner book, the drag'n'drop
> features of the IDE will not take you very far. The
> OnEditCommand=dlsAuthor_EditCommand is what associates Edit clicks
> within the DataList with an event handler, in this case Sub
> dlsAuthors_EditCommand (bottom of page 539).
>
> The SQLConnection control on the form is a simple way to have the IDE
> write some of you code for you. There are a bunch of different ways to
> connect to a db. Whatever works, works.
>
> To make the edit work, you have to have CommandName="edit" in the
> control, "OnEditCommand = dlsAuthor_EditCommand" in the DataList, and
> "datalist1.edititemindex=e.item.itemindex" within the sub routine,
> making sure that the datalist1 value is the same as the name of your
> datalist (dlstAuthors in the book).
>
> I hope this helps,
> Barry
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!

The SQL Connection method has no impact on whether or not you have to
use OnCommand. These HTML-based handlers are required regardless.

I noticed a couple of <p> tags in your editItemTemplate. If you need a
line break, try removing them or replacing them with <br> tags.

Barry

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
That is surprising I would have thought that an IDE would do that sort of
redundant stuff for you.

My edititem is fine, except it won't appear, just shows the header above the
datalist and blanks out the datalist... ?

buy my itemtemplate has no br's but still has a ton of space between each
item.. I cannot see why.

Thanks

"Barry" <barrygilbertusaATyahoo.com> wrote in message
news:#EFfStBXDHA.2524@.TK2MSFTNGP09.phx.gbl...
>
> The SQL Connection method has no impact on whether or not you have to
> use OnCommand. These HTML-based handlers are required regardless.
> I noticed a couple of <p> tags in your editItemTemplate. If you need a
> line break, try removing them or replacing them with <br> tags.
> Barry
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!

newbiew ( debugging question )

iam new to asp.net debugging, i was just wondering if there was any
option in the IDE which i can change to throw all the exceptions in the
IDE while deugging, something like VB 6's 'break on all errors' ?
TIA
-ashishThat is turned on by default.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.

"Ashish" <asharma@.mailmenot.com> wrote in message
news:uBpQXlknDHA.2000@.TK2MSFTNGP12.phx.gbl...
> iam new to asp.net debugging, i was just wondering if there was any
> option in the IDE which i can change to throw all the exceptions in the
> IDE while deugging, something like VB 6's 'break on all errors' ?
> TIA
> -ashish
Kevin Spencer wrote:
> That is turned on by default.
but it is nt stopping when an unhandled error is raised ?, i want it to
tell me while debugging, where (exact line ) the error occured
is that possible with asp.net pages debugging ?
-ashish
Well, if you go to your Debug menu, and select "Exceptions" you can
customize how and when your debugger breaks in every conceivable way.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.

"Ashish" <asharma@.mailmenot.com> wrote in message
news:OvArLCxnDHA.2964@.tk2msftngp13.phx.gbl...
> Kevin Spencer wrote:
> > That is turned on by default.
> but it is nt stopping when an unhandled error is raised ?, i want it to
> tell me while debugging, where (exact line ) the error occured
> is that possible with asp.net pages debugging ?
> -ashish