Saturday, March 31, 2012

Server side code in-side aspx

I usually use code-behind pages in ASP.Net, but occasionally I have to put my
server code inside an aspx file.
I have a problem finding the correct signature for a button click event.
Private Sub loginbtn_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles loginbtn.Click
compiles in in code behind, but it doesn't compile inside an aspx file.

How can I write a server event handler and put the code inside an asp file?That is the correct signature. What's the error you get?

-Brock
DevelopMentor
http://staff.develop.com/ballen

> I usually use code-behind pages in ASP.Net, but occasionally I have to
> put my
> server code inside an aspx file.
> I have a problem finding the correct signature for a button click
> event.
> Private Sub loginbtn_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles loginbtn.Click
> compiles in in code behind, but it doesn't compile inside an aspx
> file.
> How can I write a server event handler and put the code inside an asp
> file?

Server Side Code dependent on JavaScript

Is there a way I can launch a Server Side function from JavaScript?

On a Button Click, I am using JavaScript to print to current page. When the print has been sent, I want to run a Server Side Function to update a record (which also changes the screen so I have to wait until it prints to run the server side function).

Thanks.I imagine in your JS function, you could print and then do a postback to the server?
This may get your problem resolved.

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
Button1.Attributes.Add("onClick","javascript:DoSomething();");
string html = "";
html += "<script>";
html += " function DoSomething()";
html += " {";
html += " window.print();";
html += " }";
html += "</script>";
Response.Write(html);
}

private void Button1_Click(object sender, System.EventArgs e)
{
Update();
}

public void Update()
{
Response.Write("Now going to update the record.");
}
How to force a postback using javascript:

http://weblogs.asp.net/mnolton/archive/2003/06/04/8260.aspx

server side code access the text of <asp:label> changed by client-side javascript co

Is possible for server side code to access the text of <asp:label> changed
by client side javascript code?Yes, of course you can do it.

--
-Saravana
http://dotnetjunkies.com/WebLog/saravana/
www.ExtremeExperts.com

"nick" <nbdy9.removethis@.hotmail.com> wrote in message
news:%23UAnyAt4EHA.2600@.TK2MSFTNGP09.phx.gbl...
> Is possible for server side code to access the text of <asp:label> changed
> by client side javascript code?
No, you will need to double the new value into a hidden text field, or some
other postable field, and then look for the change of the text through the
Request.Forms["txtHidden1"] property on postback to determine if the text
has changed.

bill

"nick" <nbdy9.removethis@.hotmail.com> wrote in message
news:%23UAnyAt4EHA.2600@.TK2MSFTNGP09.phx.gbl...
> Is possible for server side code to access the text of <asp:label> changed
> by client side javascript code?
If you mean accessing the text via the label's Text property, the answer is
no.

You can pass the changed text to the server in one of the common ways of
passing values from client to server, for example in a hidden field.

Eliyahu

"nick" <nbdy9.removethis@.hotmail.com> wrote in message
news:%23UAnyAt4EHA.2600@.TK2MSFTNGP09.phx.gbl...
> Is possible for server side code to access the text of <asp:label> changed
> by client side javascript code?

server side code access the text of <asp:label> changed by client-side javascri

Is possible for server side code to access the text of <asp:label> changed
by client side javascript code?Yes, of course you can do it.
-Saravana
http://dotnetjunkies.com/WebLog/saravana/
www.ExtremeExperts.com
"nick" <nbdy9.removethis@.hotmail.com> wrote in message
news:%23UAnyAt4EHA.2600@.TK2MSFTNGP09.phx.gbl...
> Is possible for server side code to access the text of <asp:label> changed
> by client side javascript code?
>
No, you will need to double the new value into a hidden text field, or some
other postable field, and then look for the change of the text through the
Request.Forms["txtHidden1"] property on postback to determine if the text
has changed.
bill
"nick" <nbdy9.removethis@.hotmail.com> wrote in message
news:%23UAnyAt4EHA.2600@.TK2MSFTNGP09.phx.gbl...
> Is possible for server side code to access the text of <asp:label> changed
> by client side javascript code?
>
If you mean accessing the text via the label's Text property, the answer is
no.
You can pass the changed text to the server in one of the common ways of
passing values from client to server, for example in a hidden field.
Eliyahu
"nick" <nbdy9.removethis@.hotmail.com> wrote in message
news:%23UAnyAt4EHA.2600@.TK2MSFTNGP09.phx.gbl...
> Is possible for server side code to access the text of <asp:label> changed
> by client side javascript code?
>

Server Side Code..

How to decide to use WebControls.Button or HtmlControls.HtmlInputButton
controls in a web application. When I am getting the clicked event handler
for both of them on the server side. Thanks,

NelsonHi Nelson,

I would definitely go with the <asp:Button> in your case and use code
behind. This makes it easy to hook up your code if you are using an IDE
like VS.Net and will seperate your code from your UI. Good luck! Ken.

--
Ken Dopierala Jr.
For great ASP.Net web hosting try:
http://www.webhost4life.com/default.asp?refid=Spinlight
If you sign up under me and need help, email me.

"Nelson" <NelsonSmith1997@.hotmail.com> wrote in message
news:evpYtjRyEHA.3224@.TK2MSFTNGP14.phx.gbl...
> How to decide to use WebControls.Button or HtmlControls.HtmlInputButton
> controls in a web application. When I am getting the clicked event handler
> for both of them on the server side. Thanks,
> Nelson
>

Server Side code withoout page refresh

Is it possible if I can call server side code without the page
refreshing?

Thanks,

SeanShort answer : no, if it's a postback.
On the first call, yes, of course.

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
===================================
<seanmle@.gmail.com> wrote in message news:1140807565.766741.128340@.v46g2000cwv.googlegr oups.com...
> Is it possible if I can call server side code without the page
> refreshing?
> Thanks,
> Sean
yes. the techinque is call AJAX. google for toolkits. also asp.net 2.0 has a
very simple (feature wise) implementation for IE.

-- bruce (sqlwork.com)

<seanmle@.gmail.com> wrote in message
news:1140807565.766741.128340@.v46g2000cwv.googlegr oups.com...
> Is it possible if I can call server side code without the page
> refreshing?
> Thanks,
> Sean
Yes.
You can use Remote Scripting callbacks (often now referred to as "AJAX").
This normally involves using XmlHttp from the client - side page DOM to make
a call into the server-side page and call a method on it, returning the
results as either javascript, JSON, or HTML which is used to update the DOM
at the client.

The new Atlas Framework does this for ASP.NET 2.0. You could also look at
Anthem.Net and MagicAJax.net over on Sourceforge.net if you are interested in
using a whole "framework" for this type of operation.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com

"seanmle@.gmail.com" wrote:

> Is it possible if I can call server side code without the page
> refreshing?
> Thanks,
> Sean
>
Here you can find a comparison of AJAX frameworks, that allow page
updates with AJAX without reloading the whole page:
http://www.daniel-zeiss.de/AJAXComparison/Results.htm

Some frameworks allow roundtrips with ASP.NET server events without
updating any page content.
re:
>> Is it possible if I can call server side code without the page refreshing?
> yes. the techinque is call AJAX.

Sure, although you're still posting back...just not the whole page.

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
===================================
"Bruce Barker" <brubar_nospamplease_@.safeco.com> wrote in message
news:e9I1uAYOGHA.3888@.TK2MSFTNGP10.phx.gbl...
> yes. the techinque is call AJAX. google for toolkits. also asp.net 2.0 has a very simple (feature
> wise) implementation for IE.
> -- bruce (sqlwork.com)

> <seanmle@.gmail.com> wrote in message news:1140807565.766741.128340@.v46g2000cwv.googlegr oups.com...
>> Is it possible if I can call server side code without the page
>> refreshing?
>>
>> Thanks,
>>
>> Sean

Server Side code withoout page refresh

Is it possible if I can call server side code without the page
refreshing?
Thanks,
SeanShort answer : no, if it's a postback.
On the first call, yes, of course.
Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
===================================
<seanmle@.gmail.com> wrote in message news:1140807565.766741.128340@.v46g2000cwv.googlegroups
.com...
> Is it possible if I can call server side code without the page
> refreshing?
> Thanks,
> Sean
>
yes. the techinque is call AJAX. google for toolkits. also asp.net 2.0 has a
very simple (feature wise) implementation for IE.
-- bruce (sqlwork.com)
<seanmle@.gmail.com> wrote in message
news:1140807565.766741.128340@.v46g2000cwv.googlegroups.com...
> Is it possible if I can call server side code without the page
> refreshing?
> Thanks,
> Sean
>
Yes.
You can use Remote Scripting callbacks (often now referred to as "AJAX").
This normally involves using XmlHttp from the client - side page DOM to make
a call into the server-side page and call a method on it, returning the
results as either javascript, JSON, or HTML which is used to update the DOM
at the client.
The new Atlas Framework does this for ASP.NET 2.0. You could also look at
Anthem.Net and MagicAJax.net over on Sourceforge.net if you are interested i
n
using a whole "framework" for this type of operation.
Peter
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com
"seanmle@.gmail.com" wrote:

> Is it possible if I can call server side code without the page
> refreshing?
> Thanks,
> Sean
>
Here you can find a comparison of AJAX frameworks, that allow page
updates with AJAX without reloading the whole page:
http://www.daniel-zeiss.de/AJAXComparison/Results.htm
Some frameworks allow roundtrips with ASP.NET server events without
updating any page content.
re:
> yes. the techinque is call AJAX.
Sure, although you're still posting back...just not the whole page.
Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
===================================
"Bruce Barker" <brubar_nospamplease_@.safeco.com> wrote in message
news:e9I1uAYOGHA.3888@.TK2MSFTNGP10.phx.gbl...
> yes. the techinque is call AJAX. google for toolkits. also asp.net 2.0 has
a very simple (feature
> wise) implementation for IE.
> -- bruce (sqlwork.com)
> <seanmle@.gmail.com> wrote in message news:1140807565.766741.128340@.v46g200
0cwv.googlegroups.com...