Showing posts with label webform. Show all posts
Showing posts with label webform. Show all posts

Saturday, March 31, 2012

SendKeys In A Webform

I have a button to insert text into a field, after inserting the text i would like to set the cursor at the end of that text to then complete the entry
I can set the text and the focus
txtNewPrice.Text ="$"
txtNewPrice.Focus()

But how can i use the send keys to move to the end of that text
In a Windows world i would do this but i dont seem to have that function in the web world
SendKeys.Send("{END}")

you can try using javascript for that


Could you give me an example


Hi

I needed something similar this weekend. Found this and it works fine.

http://www.velocityreviews.com/forums/t70952-set-focus-and-cursor-at-end-of-text.html

Separate code file

Hi

I have a button on a webform. When I double click the button to create click
event it is created in the same file (aspx). How can I tell vs2005 to create
the code in a separate aspx.vb file?

Thanks

RegardsOn Feb 19, 4:54 am, "John" <J...@.nospam.infovis.co.ukwrote:

Quote:

Originally Posted by

Hi
>
I have a button on a webform. When I double click the button to create click
event it is created in the same file (aspx). How can I tell vs2005 to create
the code in a separate aspx.vb file?
>
Thanks
>
Regards


You enable the ASP .NET code-behind feature by adding attributes to
the @.Page directive.

for VB

<%@. Page Language="VB" Inherits="myClass" CodeBehind="myPage.aspx.vb"
%>

for C#

<%@. Page Language="C#" Inherits="myClass" CodeBehind="myPage.aspx.cs"
%>
Does that mean that it is not something one should normally be doing
otherwise it would have been provided by default?

Thanks

Regards

"Alexey Smirnov" <alexey.smirnov@.gmail.comwrote in message
news:1171872789.521209.303890@.v45g2000cwv.googlegr oups.com...

Quote:

Originally Posted by

On Feb 19, 4:54 am, "John" <J...@.nospam.infovis.co.ukwrote:

Quote:

Originally Posted by

>Hi
>>
>I have a button on a webform. When I double click the button to create
>click
>event it is created in the same file (aspx). How can I tell vs2005 to
>create
>the code in a separate aspx.vb file?
>>
>Thanks
>>
>Regards


>
You enable the ASP .NET code-behind feature by adding attributes to
the @.Page directive.
>
for VB
>
<%@. Page Language="VB" Inherits="myClass" CodeBehind="myPage.aspx.vb"
%>
>
for C#
>
<%@. Page Language="C#" Inherits="myClass" CodeBehind="myPage.aspx.cs"
%>
>


On Feb 19, 3:56 pm, "John" <J...@.nospam.infovis.co.ukwrote:

Quote:

Originally Posted by

Does that mean that it is not something one should normally be doing
otherwise it would have been provided by default?
>


VS creates that by default, when you add a new WebForm into project.
How do you created it?
Hi

I suspect I copied from another predone webform. I have now added this line
at the top;

<%@. Page Language="VB" MasterPageFile="MyMaster.master"
AutoEventWireup="false" CodeFile="MyPage.aspx.vb"
Inherits="Events_Settings_MyPage" Title="My Title" %>

and it says 'file '/Events/Settings/MyPage.aspx.vb' does not exist.' which
of course is true as the page did not have code behind to start with. How
can I now get vs to create the MyPage.aspx.vb file and link to the webform?

Thanks

Regards

"Alexey Smirnov" <alexey.smirnov@.gmail.comwrote in message
news:1171897535.364021.46260@.l53g2000cwa.googlegro ups.com...

Quote:

Originally Posted by

On Feb 19, 3:56 pm, "John" <J...@.nospam.infovis.co.ukwrote:

Quote:

Originally Posted by

>Does that mean that it is not something one should normally be doing
>otherwise it would have been provided by default?
>>


>
VS creates that by default, when you add a new WebForm into project.
How do you created it?
>


On Feb 19, 5:25 pm, "John" <J...@.nospam.infovis.co.ukwrote:

Quote:

Originally Posted by

Hi
>
I suspect I copied from another predone webform. I have now added this line
at the top;
>


Well, I think the best way is to add a new webform to your project. VS
will create aspx and the one for code-behind. Then you can copy your
code to this new webform, or use created code-behind *.vb as an
example.

Separate code file

Hi
I have a button on a webform. When I double click the button to create click
event it is created in the same file (aspx). How can I tell vs2005 to create
the code in a separate aspx.vb file?
Thanks
RegardsOn Feb 19, 4:54 am, "John" <J...@.nospam.infovis.co.uk> wrote:
> Hi
> I have a button on a webform. When I double click the button to create cli
ck
> event it is created in the same file (aspx). How can I tell vs2005 to crea
te
> the code in a separate aspx.vb file?
> Thanks
> Regards
You enable the ASP .NET code-behind feature by adding attributes to
the @.Page directive.
for VB
<%@. Page Language="VB" Inherits="myClass" CodeBehind="myPage.aspx.vb"
%>
for C#
<%@. Page Language="C#" Inherits="myClass" CodeBehind="myPage.aspx.cs"
%>
Does that mean that it is not something one should normally be doing
otherwise it would have been provided by default?
Thanks
Regards
"Alexey Smirnov" <alexey.smirnov@.gmail.com> wrote in message
news:1171872789.521209.303890@.v45g2000cwv.googlegroups.com...
> On Feb 19, 4:54 am, "John" <J...@.nospam.infovis.co.uk> wrote:
> You enable the ASP .NET code-behind feature by adding attributes to
> the @.Page directive.
> for VB
> <%@. Page Language="VB" Inherits="myClass" CodeBehind="myPage.aspx.vb"
> %>
> for C#
> <%@. Page Language="C#" Inherits="myClass" CodeBehind="myPage.aspx.cs"
> %>
>
On Feb 19, 3:56 pm, "John" <J...@.nospam.infovis.co.uk> wrote:
> Does that mean that it is not something one should normally be doing
> otherwise it would have been provided by default?
>
VS creates that by default, when you add a new WebForm into project.
How do you created it?
Hi
I suspect I copied from another predone webform. I have now added this line
at the top;
<%@. Page Language="VB" MasterPageFile="MyMaster.master"
AutoEventWireup="false" CodeFile="MyPage.aspx.vb"
Inherits="Events_Settings_MyPage" Title="My Title" %>
and it says 'file '/Events/Settings/MyPage.aspx.vb' does not exist.' which
of course is true as the page did not have code behind to start with. How
can I now get vs to create the MyPage.aspx.vb file and link to the webform?
Thanks
Regards
"Alexey Smirnov" <alexey.smirnov@.gmail.com> wrote in message
news:1171897535.364021.46260@.l53g2000cwa.googlegroups.com...
> On Feb 19, 3:56 pm, "John" <J...@.nospam.infovis.co.uk> wrote:
> VS creates that by default, when you add a new WebForm into project.
> How do you created it?
>
On Feb 19, 5:25 pm, "John" <J...@.nospam.infovis.co.uk> wrote:
> Hi
> I suspect I copied from another predone webform. I have now added this lin
e
> at the top;
>
Well, I think the best way is to add a new webform to your project. VS
will create aspx and the one for code-behind. Then you can copy your
code to this new webform, or use created code-behind *.vb as an
example.

Thursday, March 29, 2012

Separating presentation and data access tier. Best Practices for writing simple/intermedia

Hi,

I am writing a simple code, where I am a accessing database table, and based on the content of the table I dynamically generate a webform. In the webform I have a few buttons which when clicked do some dataaccess.

I have a class that performs all the dataacess, another class that I use to place the controls on the webform.
I am not sure if the code design is appropriate. The presentation and biz logic layer are not completely separated. I would like to know some best practice coding tips from the experianced ppl here. Or if anyone can send a pseudocode of his/her coding methods.

I would like to know when writing simple modules, which typically involves some dataaccess, data manipulation and then data presentation, which layer should go into the events like Page_load and CmdButton_click.

In the code below, I am not quite comfortable with SQL statement generation in the Page_Load event

My code structure looks like


Page_load()
{

string SQL="some sql stmt"
DataSet dsdata=new DataSet()
dsdata=dataaccessclass.getdata(SQL)

foreach(datarow dr in dsdata)
{

if(some condition)
//create control A
//set control properties based on dr
//call addcontrolclass.placecontrolAfunction
else
{

}

}

Cmd_Button_click()
{

//check which button is clicked
//make a SQL statment as string
//call dataaccessclass.performoperation(SQL)

}

Hey there,

I find when I'm writing, the best way to keep it all separate is to write a bindcontrols() procedure that makes calls to the logic classes/methods, this way populating your controls is done by calls the furthest away you can get from your presentation layer.

Hope it helps, it is saturday night where I am and I have had a few brewskies!

Cheers

Steve
I would seriously contemplating looking at the MS Data Access Applcation Blocks. I Class Library that takes care of your DAL quite elegantly (it's free, and all the source code is included, and it's really simple to use):

Data Access Applcation Blocks