Showing posts with label page. Show all posts
Showing posts with label page. Show all posts

Saturday, March 31, 2012

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 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...

server side control not visible in webpage

Hey there-
I have a newbie question regarding code behind:
Using inline code, I can run a simple page that binds data to a
datagrid. Now, I try to take the same code and use code behind, and
the page compiles fine, but no HTML is rendered to the page.
Here is the code from "WebForm1.aspx"
<%@dotnet.itags.org. Page Language="vb" Inherits="WebForm1" src="http://pics.10026.com/?src=WebForm1.aspx.vb" %>
<html>
<head>
<title>WebForm1</title>
</head>
<body>
<asp:datagrid id="datGrid" runat="server"/>
</body>
</html>
--
And here is the code for "WebForm1.aspx.vb"
Imports System
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Data
Public Class WebForm1
Inherits System.Web.UI.Page
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
BindData()
End Sub
Sub BindData()
'1. Create a connection
Dim AccessConn As System.Data.OleDb.OleDbConnection
Dim AccessCommand As System.Data.OleDb.OleDbCommand
Dim AccessReader As System.Data.OleDb.OleDbDataReader
Dim strConn As String
Dim datGrid As New DataGrid
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\inetpub\wwwroot\AddressBook\da
tabase\Address.mdb;"
AccessConn = New System.Data.OleDb.OleDbConnection(strConn)
'2. Create the command object, passing in the SQL string
Const strSQL As String = "SELECT ID, LastName, FirstName FROM
tblAddress ORDER BY LastName"
Dim myCommand As New System.Data.OleDb.OleDbCommand(strSQL,
AccessConn)
'Set the datagrid's datasource to the datareader and databind
AccessConn.Open()
datGrid.DataSource =
myCommand.ExecuteReader(CommandBehavior.CloseConnection)
datGrid.DataBind()
End Sub
End Class
--
A couple of notes:
1) I removed the "Web Form Designer Generated Code" for simplicity
2) Why do I need to declare datGrid? None of the examples I have seen
don't declare the server controls.
Regards,
ChristianChristian,

> 1) I removed the "Web Form Designer Generated Code" for simplicity
Don't do that! JK! I would suggest trying your example with the web form des
igner code cause your datagrid object is initialized in there. Also make sur
e your query is returning rows.
-Calvin Luttrell
ProjectThunder.com
Calvin-
I didn't remove the code from the actual aspx file, just in the
example here. My query is returning rows. Like I mentioned in the
previous post, everything works great if I use inline code, it's when
I modify it to code behind that the control doesn't render.
Christian
"Calvin Luttrell/ProjectThunder.com" <calvinl@.projectthunder.com> wrote in message news:<Ov
6WqlUQEHA.2520@.TK2MSFTNGP11.phx.gbl>...
> Christian,
>
> Don't do that! JK! I would suggest trying your example with the web form
> designer code cause your datagrid object is initialized in there. Also
> make sure your query is returning rows.
>
> -Calvin Luttrell
> ProjectThunder.com
>
>
>
>
> --

server side control not visible in webpage

Hey there-

I have a newbie question regarding code behind:

Using inline code, I can run a simple page that binds data to a
datagrid. Now, I try to take the same code and use code behind, and
the page compiles fine, but no HTML is rendered to the page.

Here is the code from "WebForm1.aspx"

------
<%@dotnet.itags.org. Page Language="vb" Inherits="WebForm1" src="http://pics.10026.com/?src=WebForm1.aspx.vb" %>
<html>
<head>
<title>WebForm1</title>
</head>
<body
<asp:datagrid id="datGrid" runat="server"/
</body>
</html>
-------

And here is the code for "WebForm1.aspx.vb"

-------
Imports System
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Data

Public Class WebForm1
Inherits System.Web.UI.Page

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
BindData()
End Sub

Sub BindData()

'1. Create a connection
Dim AccessConn As System.Data.OleDb.OleDbConnection
Dim AccessCommand As System.Data.OleDb.OleDbCommand
Dim AccessReader As System.Data.OleDb.OleDbDataReader
Dim strConn As String
Dim datGrid As New DataGrid

strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\inetpub\wwwroot\AddressBook\database\Add ress.mdb;"
AccessConn = New System.Data.OleDb.OleDbConnection(strConn)

'2. Create the command object, passing in the SQL string
Const strSQL As String = "SELECT ID, LastName, FirstName FROM
tblAddress ORDER BY LastName"
Dim myCommand As New System.Data.OleDb.OleDbCommand(strSQL,
AccessConn)

'Set the datagrid's datasource to the datareader and databind
AccessConn.Open()
datGrid.DataSource =
myCommand.ExecuteReader(CommandBehavior.CloseConne ction)
datGrid.DataBind()
End Sub

End Class
-------

A couple of notes:

1) I removed the "Web Form Designer Generated Code" for simplicity
2) Why do I need to declare datGrid? None of the examples I have seen
don't declare the server controls.

Regards,

ChristianChristian,

> 1) I removed the "Web Form Designer Generated Code" for simplicity

Don't do that! JK! I would suggest trying your example with the web form designer code cause your datagrid object is initialized in there. Also make sure your query is returning rows.

-Calvin Luttrell
ProjectThunder.com


Calvin-

I didn't remove the code from the actual aspx file, just in the
example here. My query is returning rows. Like I mentioned in the
previous post, everything works great if I use inline code, it's when
I modify it to code behind that the control doesn't render.

Christian

"Calvin Luttrell/ProjectThunder.com" <calvinl@.projectthunder.com> wrote in message news:<Ov6WqlUQEHA.2520@.TK2MSFTNGP11.phx.gbl>...
> Christian,
> > 1) I removed the "Web Form Designer Generated Code" for simplicity
> Don't do that! JK! I would suggest trying your example with the web form
> designer code cause your datagrid object is initialized in there. Also
> make sure your query is returning rows.
>
> -Calvin Luttrell
> ProjectThunder.com
>
>
>
>
> --

Server Side Controls in ASP.NET

Hi,

I have an aspx page with some server side textboxes.

I have a button onmy page which allows users to add data
to a database.

In my onclick event for my button when I try and get teh
value from the textbox using..

Dim myString as String = textbox1.text

...it is blank.

When I do a..

Dim myString = Request.Form("textbox1")

...I get the value the user enetered.

I have declared my textbox as a control in my codebehind.

And it is an asp.net textbox.

Any ideas why this is?

This is baffling me.

Kerri.Have you added the "runat=server" attribute to the template HTML for the
text box?

--
HTH,

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

"Kerri" <anonymous@.discussions.microsoft.com> wrote in message
news:017401c39cc4$12c55070$a501280a@.phx.gbl...
> Hi,
> I have an aspx page with some server side textboxes.
> I have a button onmy page which allows users to add data
> to a database.
> In my onclick event for my button when I try and get teh
> value from the textbox using..
> Dim myString as String = textbox1.text
> ..it is blank.
> When I do a..
> Dim myString = Request.Form("textbox1")
> ..I get the value the user enetered.
> I have declared my textbox as a control in my codebehind.
> And it is an asp.net textbox.
> Any ideas why this is?
> This is baffling me.
> Kerri.

Server side error

Im trying to get my first aspx page working to no avail.
Im using Visual Studio .Net and when you start web services it gives you a short Hello World program to test the server with. When i try to run it all i get is the following error message.

Unable to start debugging on server.
Server side error occured on sending debug HTTP request.

I have tried all the procedures recommended on the Microsoft error page it sends you to with no luck at all.

Anything im missing?

IIS is installed.hello, make sure IIS is on, and ke sure u have give permission to ASPNET account for the folder in which the aspx page is in !!!
Ive set the asp account to administrator access and still the same error.

For some reason unknown to me my system is running fat32. Is this a problem at all?
administrator is something and aspnet account is something else, maybe this system is makingu troubles !!!!

Server Side Error

Hello,
If you hit this page ...http://www.ourwebzone.com/calendarprintout/index.aspx
You will see the error is referring to DotNetNuke web.config. This is not right.
I am tryng to run my Calendar Printout app.
I have my CalendarPrintout (no DB used) app setup like this...
FILE STRUCTURE
---------------
www.ourwebzone.com (root)
web.config (dotnetnuke is stored in root)
global.aspx
bin (folder)
--> CalendarPrintout
web.config
global.aspx
---> bin (folder)
CalendarPrintout.DLL
How come my web.config is being ignored in my CalendarPrintout folder??
Why is the DNN web.config being hit?
I tried to put my CalendarPrintout.DLL in the domains root BIN folder, but same error.
But, if I removed the BIN folder from my CalendarPrintout folder (see) above.. I get this error?
Parser Error Message:Could not load type 'CalendarPrintout.Global'.
Source Error:
Line 1: <%@dotnet.itags.org. Application Codebehind="Global.asax.vb" Inherits="CalendarPrintout.Global" %>

What do I do??
Thanks
FrankHello,
In order to run this application you have to create a VIRTUAL DIRECTORY for CalendarPrintout

HTH
regards
I have no control of Virtual direcories on my web host, but they said that they did that.
Any other ideas?
Thanks
Hello,
I'm sure that you should use virtual directory for this folder. If you move the calander foldet to the root it will work.
anyway, check this threadhttp://forums.asp.net/1069271/ShowPost.aspx
regards

Server side function calling

Hi,
Uses: VS.NET 2003, VB.NET, Windows xp

I've written an apsx web page through vb.net. In that I've mentioned a
procedure(Server Side). Now I want to call it through Jscript.

The reason behind is about validations. There are some text to enter in one
text box. So once the user has entered the text, it will check whether the
text is null, if not it will call that server side procedure I've mentioned
in aspx page.

I'm wondering how can I call it. One guy in the news group said to use the
following:

1. __doPostBack(...);
2. document.forms[0].submit();
3. document.getElementById(<Some asp control's client ID>).click();

however it wasn't specific and I didn't understod how to use it. Using codes
to illustrate the solution will be much worthy here.

Thank you,
--
Mohammed Hifni Shahzard Nazeer,
JB Securities Pvt. Ltd.,
Colombo.Hifni Shahzard wrote:
> Hi,
> Uses: VS.NET 2003, VB.NET, Windows xp
> I've written an apsx web page through vb.net. In that I've mentioned a
> procedure(Server Side). Now I want to call it through Jscript.
> The reason behind is about validations. There are some text to enter
> in one text box. So once the user has entered the text, it will check
> whether the text is null, if not it will call that server side
> procedure I've mentioned in aspx page.
> I'm wondering how can I call it. One guy in the news group said to
> use the following:
> 1. __doPostBack(...);
> 2. document.forms[0].submit();
> 3. document.getElementById(<Some asp control's client ID>).click();
> however it wasn't specific and I didn't understod how to use it.
> Using codes to illustrate the solution will be much worthy here.
> Thank you,

If you want validation, use a CustomValidator. You could provide some
client-side javascript, but that's not required. You are after the server-side
event. There you can do your validation.

Hans Kesting
You can use the AJAX.NET libraries to asynchronously do a server side method
call easily through javascript.

Go here http://ajax.schwarz-interactive.de/...le/default.aspx for
examples and downloadable libraries and code.

--
- Paul Glavich
MVP ASP.NET
http://weblogs.asp.net/pglavich
ASPInsiders member - http://www.aspinsiders.com

"Hans Kesting" <news.2.hansdk@.spamgourmet.com> wrote in message
news:%23VZF4l%23zFHA.1968@.TK2MSFTNGP10.phx.gbl...
> Hifni Shahzard wrote:
>> Hi,
>> Uses: VS.NET 2003, VB.NET, Windows xp
>>
>> I've written an apsx web page through vb.net. In that I've mentioned a
>> procedure(Server Side). Now I want to call it through Jscript.
>>
>> The reason behind is about validations. There are some text to enter
>> in one text box. So once the user has entered the text, it will check
>> whether the text is null, if not it will call that server side
>> procedure I've mentioned in aspx page.
>>
>> I'm wondering how can I call it. One guy in the news group said to
>> use the following:
>>
>> 1. __doPostBack(...);
>> 2. document.forms[0].submit();
>> 3. document.getElementById(<Some asp control's client ID>).click();
>>
>> however it wasn't specific and I didn't understod how to use it.
>> Using codes to illustrate the solution will be much worthy here.
>>
>> Thank you,
> If you want validation, use a CustomValidator. You could provide some
> client-side javascript, but that's not required. You are after the
> server-side
> event. There you can do your validation.
> Hans Kesting

Server side function calling

Hi,
Uses: VS.NET 2003, VB.NET, Windows xp
I've written an apsx web page through vb.net. In that I've mentioned a
procedure(Server Side). Now I want to call it through Jscript.
The reason behind is about validations. There are some text to enter in one
text box. So once the user has entered the text, it will check whether the
text is null, if not it will call that server side procedure I've mentioned
in aspx page.
I'm wondering how can I call it. One guy in the news group said to use the
following:
1. __doPostBack(...);
2. document.forms[0].submit();
3. document.getElementById(<Some asp control's client ID> ).click();
however it wasn't specific and I didn't understod how to use it. Using codes
to illustrate the solution will be much worthy here.
Thank you,
--
Mohammed Hifni Shahzard Nazeer,
JB Securities Pvt. Ltd.,
Colombo.Hifni Shahzard wrote:
> Hi,
> Uses: VS.NET 2003, VB.NET, Windows xp
> I've written an apsx web page through vb.net. In that I've mentioned a
> procedure(Server Side). Now I want to call it through Jscript.
> The reason behind is about validations. There are some text to enter
> in one text box. So once the user has entered the text, it will check
> whether the text is null, if not it will call that server side
> procedure I've mentioned in aspx page.
> I'm wondering how can I call it. One guy in the news group said to
> use the following:
> 1. __doPostBack(...);
> 2. document.forms[0].submit();
> 3. document.getElementById(<Some asp control's client ID> ).click();
> however it wasn't specific and I didn't understod how to use it.
> Using codes to illustrate the solution will be much worthy here.
> Thank you,
If you want validation, use a CustomValidator. You could provide some
client-side javascript, but that's not required. You are after the server-si
de
event. There you can do your validation.
Hans Kesting
You can use the AJAX.NET libraries to asynchronously do a server side method
call easily through javascript.
Go here http://ajax.schwarz-interactive.de/...le/default.aspx for
examples and downloadable libraries and code.
- Paul Glavich
MVP ASP.NET
http://weblogs.asp.net/pglavich
ASPInsiders member - http://www.aspinsiders.com
"Hans Kesting" <news.2.hansdk@.spamgourmet.com> wrote in message
news:%23VZF4l%23zFHA.1968@.TK2MSFTNGP10.phx.gbl...
> Hifni Shahzard wrote:
> If you want validation, use a CustomValidator. You could provide some
> client-side javascript, but that's not required. You are after the
> server-side
> event. There you can do your validation.
> Hans Kesting
>

Server side forms, using more than 1 per page

Hi,

This has to be a real easy one, I must be missing some dead simple concept somewhere...or be completly stupid (which is more likely if I'm honest:)...so appologies for my stupidity here...

I'm just playing around trying to get to grips with things but I have a master page that uses a TreeView for the navigation in the LHS of the page. This requires wrapping in a <form runat=server> tag to work.

The content page that uses the master page has a gridView (or rather I wish it would do!) and this also requires wrapping in <form runat=server> tag to work. You know where this is going don't you...when I run the page, I'm politely told as my masterpeice crashes and burns "A page can have only one server-side Form tag.".

I refuse to believe that you cannot have this combination of controls in a page, I'm not exactly pushing the limits of the .Net framework here...So I'm guessing it's the way I'm doing things...what do I need to do to get this to work given that both contorls need wrapping in the FORM tag and that these are essentially 2 seperate pages (from a design point of view at least)?

many thanks for any help

Mark

You can have any number of forms, but only 1 server side form indeed. Thats because of the way the page model works, the server side form is used for postback purposes, where all controls are required to be accessible. There's nothing preventing you from having 2 submit buttons doing 2 different things however, so there really is no need for 2 forms. You can even use the CrossPagePostBack feature of .NET to post to two different other pages as required...

Thanks for the reply...

So basically I should use the FORM tag in the masterpage to "wrap" everything, including the content page placeholder, which seems to work.

I don't need the submit buttons that you mention in this situation it's just that the controls require the form tag to work (but I know where you're coming from with that). I can see that this approach with master pages might cause problems as things progress but I'll worry about that as I go..

Thanks again,


Masterpages work fine that way too, since the form tag is in the master page, and wraps all the containers. Honestly, I tend to even forget about that form tag...its just there for show more than anything.

Server side form tags

I recently ran into the following exception that I received when trying to add 2 forms to a single page:

System.Web.HttpException: A page can have only one server-side Form tag.
Does this mean that I can not use more than one form on an aspx page? Is there a way around this? This seems like it would be very restrictive if there isn't a way to handle more than one form per page...

Thanks.Correct, 1 server form per page.. you can have as many client forms as you want but just 1 server form.

It really shouldnt be an issue if you are programming the .NET way, when doing asp.net pages.

Paul Wilson does have a control that allows multiple server forms, i think its in the control gallery.

Server Side Folder Browser... Please

Hi All ...
This is first time I am Posting some thing to some site.
I realy need a help frm some body.....
I want to create a page which displays the local server folders to the user
I mean i want a folder browser on my asp.net page.
Can any body help me ?


For retrieving the folder system you should write recursive functions in order to retrieve all the folders, subfolders and files from the server.
Displaying the information can be alittle tricky. Most suitable solution is to use a Treeview component. Check the Control gallery section of this website in the navigation controls...
there are some treeview controls.
The choice of how you will display the information will affect the way you will return the information from your recursive functions...
Check this article for an example:http://www.csharpfriends.com/Articles/getArticle.aspx?articleID=109
Good Luck

Server side functionality

Hi All,

I have an html button on .aspx page.

<INPUT class="sbttn" id="btnComplete0" onclick="onComplete
()" type="button" value="Mark Completed"
name="btnComplete0"
When the user clicks on the html button the OnComplete
function is called.

<script language="javascript">
function onComplete()
{

// Client side code

// Clicking the server control via code
WorkItemForm.btnComplete.click();

}
</script
I need to perform some server side functinality whenever
user clicks the html button. So I place a hidden server
control (id = btnComplete) on the .aspx page. In the
client side code I automatically click the server control
( WorkItemForm.btnComplete.click();).

On the click event of hidden server control, I write the
server side code in .aspx.cs page.

// Code in .aspx.cs page

private void btnComplete_Click(object sender,
System.EventArgs e)
{
// Calling Server Side Code
}

I am using btnComplete server control as an intermediate
to perform server side functionality.

Problem:

I want to get rid of server control.
Is there a way to perform server side functionality
directly without using server control.

I tried document.FormName.Submit();

This doesn't work. Is there some other way to do so?

Thanks & Regards,
-ReetuHi Reetu,

Here's some VB code that might help you. It uses the submit() method. Not sure
why it didn't work for you.

Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
Literal1.Text = "<script>function
onCompleted(){alert('action');document.forms[0].submit();}</script>"
If IsPostBack Then
Label2.Text = "I was posted back at: " & Now.TimeOfDay.ToString
End If
End Sub

<form id="Form1" method="post" runat="server">
<p>
<asp:textbox id="TextBox1" runat="server"></asp:textbox></p>
<p>
<asp:label id="Label2" runat="server"></asp:label></p>
<p>
<asp:label id="Label1" runat="server"></asp:label></p>
<p>
<asp:literal id="Literal1" runat="server"></asp:literal></p>
<p> </p>
<p> </p>
<input class="sbttn" id="btnComplete0" onclick="onCompleted()"
type="button" value="Mark Completed"
name="btnComplete0">
</form
"Reetu" <reetu@.ascentn.com> wrote in message
news:06c901c35c60$5aabcc10$a301280a@.phx.gbl...
Hi All,

I have an html button on .aspx page.

<INPUT class="sbttn" id="btnComplete0" onclick="onComplete
()" type="button" value="Mark Completed"
name="btnComplete0"
When the user clicks on the html button the OnComplete
function is called.

<script language="javascript">
function onComplete()
{

// Client side code

// Clicking the server control via code
WorkItemForm.btnComplete.click();

}
</script
I need to perform some server side functinality whenever
user clicks the html button. So I place a hidden server
control (id = btnComplete) on the .aspx page. In the
client side code I automatically click the server control
( WorkItemForm.btnComplete.click();).

On the click event of hidden server control, I write the
server side code in .aspx.cs page.

// Code in .aspx.cs page

private void btnComplete_Click(object sender,
System.EventArgs e)
{
// Calling Server Side Code
}

I am using btnComplete server control as an intermediate
to perform server side functionality.

Problem:

I want to get rid of server control.
Is there a way to perform server side functionality
directly without using server control.

I tried document.FormName.Submit();

This doesn't work. Is there some other way to do so?

Thanks & Regards,
-Reetu

When your page is loaded, checl the HTML source of your page. Your
hidden button will not be rendered at all.

Instead, you can convert your button to a aspx button and add
Javascript event to it from the code behind using

Add this line of code to your page load event.
ButtonName.Attributes.add("onClick","return onComplete()")

Now when you click on your button it will raise the onclick event on
the client side and will call onComplete Javascript function. Inside
the Javascript if you return false, the form will not be submitted and
the server side event of your button will not fire. If you return
true, form will be submitted to the server and your button's onclick
event will be fired on the server.

--
Ram

"Reetu" <reetu@.ascentn.com> wrote in message news:<06c901c35c60$5aabcc10$a301280a@.phx.gbl>...
> Hi All,
> I have an html button on .aspx page.
> <INPUT class="sbttn" id="btnComplete0" onclick="onComplete
> ()" type="button" value="Mark Completed"
> name="btnComplete0">
> When the user clicks on the html button the OnComplete
> function is called.
> <script language="javascript">
> function onComplete()
> {
> // Client side code
> // Clicking the server control via code
> WorkItemForm.btnComplete.click();
> }
> </script>
>
> I need to perform some server side functinality whenever
> user clicks the html button. So I place a hidden server
> control (id = btnComplete) on the .aspx page. In the
> client side code I automatically click the server control
> ( WorkItemForm.btnComplete.click();).
> On the click event of hidden server control, I write the
> server side code in .aspx.cs page.
> // Code in .aspx.cs page
> private void btnComplete_Click(object sender,
> System.EventArgs e)
> {
> // Calling Server Side Code
> }
> I am using btnComplete server control as an intermediate
> to perform server side functionality.
> Problem:
> I want to get rid of server control.
> Is there a way to perform server side functionality
> directly without using server control.
> I tried document.FormName.Submit();
> This doesn't work. Is there some other way to do so?
> Thanks & Regards,
> -Reetu
Thanks a lot, it works.

Regards,
-Reetu

>--Original Message--
>When your page is loaded, checl the HTML source of your
page. Your
>hidden button will not be rendered at all.
>Instead, you can convert your button to a aspx button and
add
>Javascript event to it from the code behind using
>Add this line of code to your page load event.
>ButtonName.Attributes.add("onClick","return onComplete()")
>Now when you click on your button it will raise the
onclick event on
>the client side and will call onComplete Javascript
function. Inside
>the Javascript if you return false, the form will not be
submitted and
>the server side event of your button will not fire. If
you return
>true, form will be submitted to the server and your
button's onclick
>event will be fired on the server.
>--
>Ram
>"Reetu" <reetu@.ascentn.com> wrote in message
news:<06c901c35c60$5aabcc10$a301280a@.phx.gbl>...
>> Hi All,
>>
>> I have an html button on .aspx page.
>>
>> <INPUT class="sbttn" id="btnComplete0"
onclick="onComplete
>> ()" type="button" value="Mark Completed"
>> name="btnComplete0">
>>
>> When the user clicks on the html button the OnComplete
>> function is called.
>>
>> <script language="javascript">
>> function onComplete()
>> {
>>
>> // Client side code
>>
>> // Clicking the server control via code
>> WorkItemForm.btnComplete.click();
>>
>> }
>> </script>
>>
>>
>> I need to perform some server side functinality
whenever
>> user clicks the html button. So I place a hidden server
>> control (id = btnComplete) on the .aspx page. In the
>> client side code I automatically click the server
control
>> ( WorkItemForm.btnComplete.click();).
>>
>> On the click event of hidden server control, I write
the
>> server side code in .aspx.cs page.
>>
>> // Code in .aspx.cs page
>>
>> private void btnComplete_Click(object sender,
>> System.EventArgs e)
>> {
>> // Calling Server Side Code
>> }
>>
>> I am using btnComplete server control as an
intermediate
>> to perform server side functionality.
>>
>> Problem:
>>
>> I want to get rid of server control.
>> Is there a way to perform server side functionality
>> directly without using server control.
>>
>> I tried document.FormName.Submit();
>>
>> This doesn't work. Is there some other way to do so?
>>
>> Thanks & Regards,
>> -Reetu
>.

Server side includes

Most of my web sites use server side includes to insert pieces of HTML design into the top and bottom of a page.

This has always worked fine with dreamweaver but now I am using VS2005 It doesn't seem to open these includes when viewing the site pages and therefore cannot switch to the design view.

Is there a way around this as otherwise I am completely stuck with dreamweaver and I really want to switch over to .net.

David Meagor

http://FreeOnlineSurveys.com

In VS2005, you may useMaster Pages and Content Pages or usercontrols to replace the inclues you used in classic asp.

The master page feature looks useful but with 300 or so classic ASP pages which have yet to be converted this isn't going to be practical.

It's such a shame that MS haven't provided support for server side includes in their editor as macromedia have with dreamweaver - it seems like such a simple feature to implement.

David Meagor

http://freeonlinesurveys.com

server side include or user control?

I am setting up an asp.net site using the Ektron CMS. Every page in the
site uses the same basic template, with the look of the page changing
via CSS and an id on the body. The id is shared by all pages in a
subsection, e.g. everything in /about/ needs to have <body id="about">.
In the past what I've done is set a global variable in index.asp, then
include the template to render the page:
<%
pageid = "about"
defaultcontentid = 33
%>
<!--#include virtual="/include/mastertemplate.asp" -->
mastertemplate.asp would be the entire page, echoing and processing the
variables like so:
<!--#include virtual="/include/cmsfunctions.asp" -->
<body id="<%= pageid %>">
<%= cmsRenderContent(defaultcontentid) %>
This worked great. I needed one index.asp for each subsection, and had
no duplication of template code. If the template needed to be updated, I
just gave it to the designer, who modified it in Dreamweaver or
whatever. The separation between presentation and logic was good, and
any code that generated html was in an easily-modified function.
I've experimented with a similar approach in asp.net, and have the start
of it working, but the additional complication is that
mastertemplate.aspx has some codebehind related to the cms server
controls that it uses, and I need to use the passed-in variables within
that codebehind. For example, I'd establish a default content id in the
calling page, and if the mastertemplate.asp doesn't detect an id in the
url, it will use the default.
I am looking for examples of this approach in asp.net but I keep running
across advice to use user controls instead. But it seems like user
controls are used for parts of pages, not the page template itself. Is
that right? Can a user control contain server controls? How would I pass
variables from a "stub" calling page to the user control page? Can a
user control be modified in something like Dreamweaver?
Thanks,
markgenerally they are right.
You will typically put a "place holder" into the template and then replace
that "place holder" with content created from a control (.ascx file). the
content is injected into the position of the "place holder" by using the
page.loadcontrol method.
example:
--
...somewhere in your code
' Dynamically inject a signin login module into the page
'---
If Request.IsAuthenticated = False Then
LoginControl.Controls.Add(Page.LoadControl("~/SignIn.ascx"))
End If
... somewhere in your template
<asp:placeholder id="LoginControl" runat="server" />
"Mark" <mark12b@.yahoo.com> wrote in message
news:mark12b-F29D08.12133710052005@.news.isp.giganews.com...
>I am setting up an asp.net site using the Ektron CMS. Every page in the
> site uses the same basic template, with the look of the page changing
> via CSS and an id on the body. The id is shared by all pages in a
> subsection, e.g. everything in /about/ needs to have <body id="about">.
> In the past what I've done is set a global variable in index.asp, then
> include the template to render the page:
> <%
> pageid = "about"
> defaultcontentid = 33
> %>
> <!--#include virtual="/include/mastertemplate.asp" -->
> mastertemplate.asp would be the entire page, echoing and processing the
> variables like so:
> <!--#include virtual="/include/cmsfunctions.asp" -->
> <body id="<%= pageid %>">
> <%= cmsRenderContent(defaultcontentid) %>
> This worked great. I needed one index.asp for each subsection, and had
> no duplication of template code. If the template needed to be updated, I
> just gave it to the designer, who modified it in Dreamweaver or
> whatever. The separation between presentation and logic was good, and
> any code that generated html was in an easily-modified function.
> I've experimented with a similar approach in asp.net, and have the start
> of it working, but the additional complication is that
> mastertemplate.aspx has some codebehind related to the cms server
> controls that it uses, and I need to use the passed-in variables within
> that codebehind. For example, I'd establish a default content id in the
> calling page, and if the mastertemplate.asp doesn't detect an id in the
> url, it will use the default.
> I am looking for examples of this approach in asp.net but I keep running
> across advice to use user controls instead. But it seems like user
> controls are used for parts of pages, not the page template itself. Is
> that right? Can a user control contain server controls? How would I pass
> variables from a "stub" calling page to the user control page? Can a
> user control be modified in something like Dreamweaver?
> Thanks,
> --
> mark
Include files are old fashioned.
User controls are a better approach. Yes, they can contain any kind of
controls you'd like. You can create public properties, methods, and events
to facilitate communication between the user control and the page.
I agree with you that user controls do not fully achieve the "template"
functionality you s as gracefully as we'd all like, but the only great
solution is in ASP.NET 2.0 (due out later this year) which implements
"Master Pages".
Here's more info:
http://SteveOrr.net/faq/usercustom.aspx
http://www.c-sharpcorner.com/Code/2...MasterPages.asp
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Mark" <mark12b@.yahoo.com> wrote in message
news:mark12b-F29D08.12133710052005@.news.isp.giganews.com...
>I am setting up an asp.net site using the Ektron CMS. Every page in the
> site uses the same basic template, with the look of the page changing
> via CSS and an id on the body. The id is shared by all pages in a
> subsection, e.g. everything in /about/ needs to have <body id="about">.
> In the past what I've done is set a global variable in index.asp, then
> include the template to render the page:
> <%
> pageid = "about"
> defaultcontentid = 33
> %>
> <!--#include virtual="/include/mastertemplate.asp" -->
> mastertemplate.asp would be the entire page, echoing and processing the
> variables like so:
> <!--#include virtual="/include/cmsfunctions.asp" -->
> <body id="<%= pageid %>">
> <%= cmsRenderContent(defaultcontentid) %>
> This worked great. I needed one index.asp for each subsection, and had
> no duplication of template code. If the template needed to be updated, I
> just gave it to the designer, who modified it in Dreamweaver or
> whatever. The separation between presentation and logic was good, and
> any code that generated html was in an easily-modified function.
> I've experimented with a similar approach in asp.net, and have the start
> of it working, but the additional complication is that
> mastertemplate.aspx has some codebehind related to the cms server
> controls that it uses, and I need to use the passed-in variables within
> that codebehind. For example, I'd establish a default content id in the
> calling page, and if the mastertemplate.asp doesn't detect an id in the
> url, it will use the default.
> I am looking for examples of this approach in asp.net but I keep running
> across advice to use user controls instead. But it seems like user
> controls are used for parts of pages, not the page template itself. Is
> that right? Can a user control contain server controls? How would I pass
> variables from a "stub" calling page to the user control page? Can a
> user control be modified in something like Dreamweaver?
> Thanks,
> --
> mark
In article <#3rMAzZVFHA.3696@.TK2MSFTNGP10.phx.gbl>,
"Steve C. Orr [MVP, MCSD]" <Steve@.Orr.net> wrote:

> I agree with you that user controls do not fully achieve the "template"
> functionality you s as gracefully as we'd all like, but the only great
> solution is in ASP.NET 2.0 (due out later this year) which implements
> "Master Pages".
> Here's more info:
> http://SteveOrr.net/faq/usercustom.aspx
> http://www.c-sharpcorner.com/Code/2...MasterPages.asp
Yes, Master Pages is most like what I was after. Now I am thinking about
just passing the section name in the url and have everything run through
a single page. Instead of
/about/index.aspx?id=123
/portfolio/index.aspx?id=456
I'll go
/index.aspx?s=about&id=123
/index.aspx?s=portfolio&id=456
This should work fine, especially since the cms has url aliasing.
Thnkas,
Yes, I've tried that approach before and it's not as easy as it might seem
at first.
Since everything is essentially a postback to the same page, this opens up
new hassles related to dynamically creating controls at runtime and managing
them all between postbacks and keeping them from conflicting with eachother
in various ways.
If you can, skip to ASP.NET 2.0 and use master pages. Otherwise I'd suggest
you use multiple pages with header and/or footer controls to help manage a
common look & feel.
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Mark" <mark12b@.yahoo.com> wrote in message
news:mark12b-377F1D.14180810052005@.news.isp.giganews.com...
> In article <#3rMAzZVFHA.3696@.TK2MSFTNGP10.phx.gbl>,
> "Steve C. Orr [MVP, MCSD]" <Steve@.Orr.net> wrote:
>
> Yes, Master Pages is most like what I was after. Now I am thinking about
> just passing the section name in the url and have everything run through
> a single page. Instead of
> /about/index.aspx?id=123
> /portfolio/index.aspx?id=456
> I'll go
> /index.aspx?s=about&id=123
> /index.aspx?s=portfolio&id=456
> This should work fine, especially since the cms has url aliasing.
> Thnkas,

server side include or user control?

I am setting up an asp.net site using the Ektron CMS. Every page in the
site uses the same basic template, with the look of the page changing
via CSS and an id on the body. The id is shared by all pages in a
subsection, e.g. everything in /about/ needs to have <body id="about">.

In the past what I've done is set a global variable in index.asp, then
include the template to render the page:

<%
pageid = "about"
defaultcontentid = 33
%>
<!--#include virtual="/include/mastertemplate.asp" --
mastertemplate.asp would be the entire page, echoing and processing the
variables like so:

<!--#include virtual="/include/cmsfunctions.asp" -->
<body id="<%= pageid %>">
<%= cmsRenderContent(defaultcontentid) %
This worked great. I needed one index.asp for each subsection, and had
no duplication of template code. If the template needed to be updated, I
just gave it to the designer, who modified it in Dreamweaver or
whatever. The separation between presentation and logic was good, and
any code that generated html was in an easily-modified function.

I've experimented with a similar approach in asp.net, and have the start
of it working, but the additional complication is that
mastertemplate.aspx has some codebehind related to the cms server
controls that it uses, and I need to use the passed-in variables within
that codebehind. For example, I'd establish a default content id in the
calling page, and if the mastertemplate.asp doesn't detect an id in the
url, it will use the default.

I am looking for examples of this approach in asp.net but I keep running
across advice to use user controls instead. But it seems like user
controls are used for parts of pages, not the page template itself. Is
that right? Can a user control contain server controls? How would I pass
variables from a "stub" calling page to the user control page? Can a
user control be modified in something like Dreamweaver?

Thanks,

--
markgenerally they are right.

You will typically put a "place holder" into the template and then replace
that "place holder" with content created from a control (.ascx file). the
content is injected into the position of the "place holder" by using the
page.loadcontrol method.

example:
--------
...somewhere in your code

' Dynamically inject a signin login module into the page
'---------------------
If Request.IsAuthenticated = False Then
LoginControl.Controls.Add(Page.LoadControl("~/SignIn.ascx"))
End If

.... somewhere in your template

<asp:placeholder id="LoginControl" runat="server" /
"Mark" <mark12b@.yahoo.com> wrote in message
news:mark12b-F29D08.12133710052005@.news.isp.giganews.com...
>I am setting up an asp.net site using the Ektron CMS. Every page in the
> site uses the same basic template, with the look of the page changing
> via CSS and an id on the body. The id is shared by all pages in a
> subsection, e.g. everything in /about/ needs to have <body id="about">.
> In the past what I've done is set a global variable in index.asp, then
> include the template to render the page:
> <%
> pageid = "about"
> defaultcontentid = 33
> %>
> <!--#include virtual="/include/mastertemplate.asp" -->
> mastertemplate.asp would be the entire page, echoing and processing the
> variables like so:
> <!--#include virtual="/include/cmsfunctions.asp" -->
> <body id="<%= pageid %>">
> <%= cmsRenderContent(defaultcontentid) %>
> This worked great. I needed one index.asp for each subsection, and had
> no duplication of template code. If the template needed to be updated, I
> just gave it to the designer, who modified it in Dreamweaver or
> whatever. The separation between presentation and logic was good, and
> any code that generated html was in an easily-modified function.
> I've experimented with a similar approach in asp.net, and have the start
> of it working, but the additional complication is that
> mastertemplate.aspx has some codebehind related to the cms server
> controls that it uses, and I need to use the passed-in variables within
> that codebehind. For example, I'd establish a default content id in the
> calling page, and if the mastertemplate.asp doesn't detect an id in the
> url, it will use the default.
> I am looking for examples of this approach in asp.net but I keep running
> across advice to use user controls instead. But it seems like user
> controls are used for parts of pages, not the page template itself. Is
> that right? Can a user control contain server controls? How would I pass
> variables from a "stub" calling page to the user control page? Can a
> user control be modified in something like Dreamweaver?
> Thanks,
> --
> mark
Include files are old fashioned.
User controls are a better approach. Yes, they can contain any kind of
controls you'd like. You can create public properties, methods, and events
to facilitate communication between the user control and the page.
I agree with you that user controls do not fully achieve the "template"
functionality you seek as gracefully as we'd all like, but the only great
solution is in ASP.NET 2.0 (due out later this year) which implements
"Master Pages".

Here's more info:
http://SteveOrr.net/faq/usercustom.aspx
http://www.c-sharpcorner.com/Code/2...MasterPages.asp

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

"Mark" <mark12b@.yahoo.com> wrote in message
news:mark12b-F29D08.12133710052005@.news.isp.giganews.com...
>I am setting up an asp.net site using the Ektron CMS. Every page in the
> site uses the same basic template, with the look of the page changing
> via CSS and an id on the body. The id is shared by all pages in a
> subsection, e.g. everything in /about/ needs to have <body id="about">.
> In the past what I've done is set a global variable in index.asp, then
> include the template to render the page:
> <%
> pageid = "about"
> defaultcontentid = 33
> %>
> <!--#include virtual="/include/mastertemplate.asp" -->
> mastertemplate.asp would be the entire page, echoing and processing the
> variables like so:
> <!--#include virtual="/include/cmsfunctions.asp" -->
> <body id="<%= pageid %>">
> <%= cmsRenderContent(defaultcontentid) %>
> This worked great. I needed one index.asp for each subsection, and had
> no duplication of template code. If the template needed to be updated, I
> just gave it to the designer, who modified it in Dreamweaver or
> whatever. The separation between presentation and logic was good, and
> any code that generated html was in an easily-modified function.
> I've experimented with a similar approach in asp.net, and have the start
> of it working, but the additional complication is that
> mastertemplate.aspx has some codebehind related to the cms server
> controls that it uses, and I need to use the passed-in variables within
> that codebehind. For example, I'd establish a default content id in the
> calling page, and if the mastertemplate.asp doesn't detect an id in the
> url, it will use the default.
> I am looking for examples of this approach in asp.net but I keep running
> across advice to use user controls instead. But it seems like user
> controls are used for parts of pages, not the page template itself. Is
> that right? Can a user control contain server controls? How would I pass
> variables from a "stub" calling page to the user control page? Can a
> user control be modified in something like Dreamweaver?
> Thanks,
> --
> mark
In article <#3rMAzZVFHA.3696@.TK2MSFTNGP10.phx.gbl>,
"Steve C. Orr [MVP, MCSD]" <Steve@.Orr.net> wrote:

> I agree with you that user controls do not fully achieve the "template"
> functionality you seek as gracefully as we'd all like, but the only great
> solution is in ASP.NET 2.0 (due out later this year) which implements
> "Master Pages".
> Here's more info:
> http://SteveOrr.net/faq/usercustom.aspx
> http://www.c-sharpcorner.com/Code/2...MasterPages.asp

Yes, Master Pages is most like what I was after. Now I am thinking about
just passing the section name in the url and have everything run through
a single page. Instead of

/about/index.aspx?id=123
/portfolio/index.aspx?id=456

I'll go

/index.aspx?s=about&id=123
/index.aspx?s=portfolio&id=456

This should work fine, especially since the cms has url aliasing.

Thnkas,
Yes, I've tried that approach before and it's not as easy as it might seem
at first.
Since everything is essentially a postback to the same page, this opens up
new hassles related to dynamically creating controls at runtime and managing
them all between postbacks and keeping them from conflicting with eachother
in various ways.
If you can, skip to ASP.NET 2.0 and use master pages. Otherwise I'd suggest
you use multiple pages with header and/or footer controls to help manage a
common look & feel.

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

"Mark" <mark12b@.yahoo.com> wrote in message
news:mark12b-377F1D.14180810052005@.news.isp.giganews.com...
> In article <#3rMAzZVFHA.3696@.TK2MSFTNGP10.phx.gbl>,
> "Steve C. Orr [MVP, MCSD]" <Steve@.Orr.net> wrote:
>> I agree with you that user controls do not fully achieve the "template"
>> functionality you seek as gracefully as we'd all like, but the only great
>> solution is in ASP.NET 2.0 (due out later this year) which implements
>> "Master Pages".
>>
>> Here's more info:
>> http://SteveOrr.net/faq/usercustom.aspx
>> http://www.c-sharpcorner.com/Code/2...MasterPages.asp
> Yes, Master Pages is most like what I was after. Now I am thinking about
> just passing the section name in the url and have everything run through
> a single page. Instead of
> /about/index.aspx?id=123
> /portfolio/index.aspx?id=456
> I'll go
> /index.aspx?s=about&id=123
> /index.aspx?s=portfolio&id=456
> This should work fine, especially since the cms has url aliasing.
> Thnkas,

server side javascript array

I am trying to load an array on the load of a page to javascript. the
script will eventually have parts being loaded from a database... this is
just a first step to get there... Here is the code
Dim mScript As New System.Text.StringBuilder
mScript = mScript.Append("<script type='text/javascript'>" & vbNewLine)
mScript.Append("var mIconAry = new Array();" & vbNewLine)
mScript.Append("mIconAry[" & 0 & "]='" &
"http://maps.google.com/mapfiles/ms/icons/purple-pushpin.png" & "';" &
vbNewLine)
mScript.Append("mIconAry[" & 1 & "]='" &
"http://maps.google.com/mapfiles/ms/icons/green-pushpin.png" & "';" &
vbNewLine)
'mScript.Append("var mInfoBox = new Array();" & vbNewLine)
'mscript.Append("mInfoBox[" & 0 & "]='" &
mScript.Append("</script>")
RegisterStartupScript("RegisterClientScriptBlock", mScript.ToString())
when i run this.. the javascript isn't there. I've tried looking using
firefox and a plugin that allows you to see all the javascript and it's not
there.. i'm using the same technique as i've used on another page and it
works there.. i don't think i've left anything out.
I'd like to use this array to put pushpins onto a microsoft virutal earth
map that i'm using. anyway.. anyone have any idea's what i'm doing wrong
in my code above.
thanks
shannonWhy don't you use the RegisterArrayDeclaration method?
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"jvcoach23" <shannonr@.sucss.state.il.us> wrote in message
news:1383ly3ijx2rg$.s770m2o8r3kg$.dlg@.40tude.net...
>I am trying to load an array on the load of a page to javascript. the
> script will eventually have parts being loaded from a database... this is
> just a first step to get there... Here is the code
> Dim mScript As New System.Text.StringBuilder
> mScript = mScript.Append("<script type='text/javascript'>" & vbNewLine)
> mScript.Append("var mIconAry = new Array();" & vbNewLine)
> mScript.Append("mIconAry[" & 0 & "]='" &
> "http://maps.google.com/mapfiles/ms/icons/purple-pushpin.png" & "';" &
> vbNewLine)
> mScript.Append("mIconAry[" & 1 & "]='" &
> "http://maps.google.com/mapfiles/ms/icons/green-pushpin.png" & "';" &
> vbNewLine)
> 'mScript.Append("var mInfoBox = new Array();" & vbNewLine)
> 'mscript.Append("mInfoBox[" & 0 & "]='" &
> mScript.Append("</script>")
> RegisterStartupScript("RegisterClientScriptBlock", mScript.ToString())
> when i run this.. the javascript isn't there. I've tried looking using
> firefox and a plugin that allows you to see all the javascript and it's
> not
> there.. i'm using the same technique as i've used on another page and it
> works there.. i don't think i've left anything out.
> I'd like to use this array to put pushpins onto a microsoft virutal earth
> map that i'm using. anyway.. anyone have any idea's what i'm doing wrong
> in my code above.
> thanks
> shannon
Thanks
in doing a little searching... i see this
RegisterArrayDeclaration("TextBoxes","TextBox1")
RegisterArrayDeclaration("TextBoxes", "TextBox2")
and they say that it will produce
<script language="javascript" >
<!--
var TextBoxes = new Array(TextBox1, TextBox2);
// -->
</script>
is it as simple as that to get the array in there... i've tried it.. the
array is not showing up in the javascript.. so i'm just curious if what
i've read is incorrect.
thanks
I added the ClientScript.RegisterArrayDeclaration("mIconAry",
"http://maps.google.com/mapfiles/ms/icons/purple-pushpin.png")
to another page.. and when the page renders.. it puts the array in
var mIconAry = new
Array(http://maps.google.com/mapfiles/ms/...ple-pushpin.png);
but when i try it on a different page, within the same project... on the
page with the microsoft map... it doesn't show up...
hope that is helpful
shannon
the non-woprking page probably does a redirect, so none of its html is of an
y
use.
-- bruce (sqlwork.com)
"jvcoach23" wrote:

> I added the ClientScript.RegisterArrayDeclaration("mIconAry",
> "http://maps.google.com/mapfiles/ms/icons/purple-pushpin.png")
> to another page.. and when the page renders.. it puts the array in
> var mIconAry = new
> Array(http://maps.google.com/mapfiles/ms/...ple-pushpin.png);
> but when i try it on a different page, within the same project... on the
> page with the microsoft map... it doesn't show up...
> hope that is helpful
> shannon
>
Found the problem... the line needed to read
ClientScript.RegisterArrayDeclaration("mIconAry",
"'http://maps.google.com/mapfiles/ms/icons/purple-pushpin.png'")
I needed the single ' inside of the double "
thanks
shannon

Thursday, March 29, 2012

Server side menu problem

Hi,
I have a frameset page that contains two frames:
1. the first frame, an aspx page, contains a menu for navigating in the
website.
2. the second frame contains content, pdf, html or other aspx files
The problem is that the menu activates a server-side methods when the user
clicks on one of the menu items.
However, from the server side I cannot control in which frame the content
will appears, it will always be in the menu frame itself.
So, how can I control from a server side function the frame to display the
content?
Is it even possible?
If not, how to avoid it without using client-based menus?
Thanks, Ohad
Ohad Young
Medical Informatics Research Center
Ben Gurion University
Information System Eng
Office Phone: 972-8-6477160
Cellular Phone: 972-54-518301
E-Mail: ohadyn@dotnet.itags.org.bgumail.bgu.ac.ilOhad,
How does your server-side menu navigate to another page? In other words,
when you click on a menu item, what component originates postback? This
component should have property "target" where you can specify the frame
name.
Eliyahu
"Ohad Young" <ohadyn@.bgumail.bgu.ac.il> wrote in message
news:O4PqPK2XEHA.3044@.TK2MSFTNGP09.phx.gbl...
> Hi,
> I have a frameset page that contains two frames:
> 1. the first frame, an aspx page, contains a menu for navigating in the
> website.
> 2. the second frame contains content, pdf, html or other aspx files
> The problem is that the menu activates a server-side methods when the user
> clicks on one of the menu items.
> However, from the server side I cannot control in which frame the content
> will appears, it will always be in the menu frame itself.
> So, how can I control from a server side function the frame to display the
> content?
> Is it even possible?
> If not, how to avoid it without using client-based menus?
> Thanks, Ohad
> --
> Ohad Young
> Medical Informatics Research Center
> Ben Gurion University
> Information System Eng
> Office Phone: 972-8-6477160
> Cellular Phone: 972-54-518301
> E-Mail: ohadyn@.bgumail.bgu.ac.il
>
Frames, by their nature, are client side objects.
What is your reasoning for wanting navigation to occur on the server? Which
controls are you using in the menu? If I'm following that correctly then
this architecture doesn't make sense to me since navigation itself is also
really a client side operation in that the client requests the page to
navigate to and the server merely provides it back to the client.
If you're doing some type of processing then calling Response.Redirect() or
Server.Transfer(), couldn't you create a redirection page that performs the
appropriate processing then redirects and link to the redirection page? If
you're not doing any processing other than a redirect you should just link
directly to the desired file. In either case, just set the target attribute
to the appropriate frame.
You could probably also get away with setting the target attribute of the
form to the desired frame...
If you're still against using a client based mechanism, then your option
becomes convert the menu to a WebControl and ditch the frames.
Anything you can do to reduce the number of round trips to the server will
improve your application's performance. Doing a postback then
Response.Redirect() results in two round trips. Requesting a redirection
page and calling Response.Redirect results in two round trips. Linking to
the page directly or using Server.Transfer() results in one round trip.
"Ohad Young" <ohadyn@.bgumail.bgu.ac.il> wrote in message
news:O4PqPK2XEHA.3044@.TK2MSFTNGP09.phx.gbl...
> Hi,
> I have a frameset page that contains two frames:
> 1. the first frame, an aspx page, contains a menu for navigating in the
> website.
> 2. the second frame contains content, pdf, html or other aspx files
> The problem is that the menu activates a server-side methods when the user
> clicks on one of the menu items.
> However, from the server side I cannot control in which frame the content
> will appears, it will always be in the menu frame itself.
> So, how can I control from a server side function the frame to display the
> content?
> Is it even possible?
> If not, how to avoid it without using client-based menus?
> Thanks, Ohad
> --
> Ohad Young
> Medical Informatics Research Center
> Ben Gurion University
> Information System Eng
> Office Phone: 972-8-6477160
> Cellular Phone: 972-54-518301
> E-Mail: ohadyn@.bgumail.bgu.ac.il
>
hi ohad, did you find the answer?
i have the same problem as well.
10x, alon.
****************************************
******************************
Sent via Fuzzy Software @. http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET
resources...

Server side menu problem

Hi,

I have a frameset page that contains two frames:
1. the first frame, an aspx page, contains a menu for navigating in the
website.
2. the second frame contains content, pdf, html or other aspx files
The problem is that the menu activates a server-side methods when the user
clicks on one of the menu items.
However, from the server side I cannot control in which frame the content
will appears, it will always be in the menu frame itself.
So, how can I control from a server side function the frame to display the
content?
Is it even possible?
If not, how to avoid it without using client-based menus?

Thanks, Ohad

--
Ohad Young
Medical Informatics Research Center
Ben Gurion University
Information System Eng
Office Phone: 972-8-6477160
Cellular Phone: 972-54-518301
E-Mail: ohadyn@dotnet.itags.org.bgumail.bgu.ac.ilOhad,

How does your server-side menu navigate to another page? In other words,
when you click on a menu item, what component originates postback? This
component should have property "target" where you can specify the frame
name.

Eliyahu

"Ohad Young" <ohadyn@.bgumail.bgu.ac.il> wrote in message
news:O4PqPK2XEHA.3044@.TK2MSFTNGP09.phx.gbl...
> Hi,
> I have a frameset page that contains two frames:
> 1. the first frame, an aspx page, contains a menu for navigating in the
> website.
> 2. the second frame contains content, pdf, html or other aspx files
> The problem is that the menu activates a server-side methods when the user
> clicks on one of the menu items.
> However, from the server side I cannot control in which frame the content
> will appears, it will always be in the menu frame itself.
> So, how can I control from a server side function the frame to display the
> content?
> Is it even possible?
> If not, how to avoid it without using client-based menus?
> Thanks, Ohad
> --
> Ohad Young
> Medical Informatics Research Center
> Ben Gurion University
> Information System Eng
> Office Phone: 972-8-6477160
> Cellular Phone: 972-54-518301
> E-Mail: ohadyn@.bgumail.bgu.ac.il
Frames, by their nature, are client side objects.

What is your reasoning for wanting navigation to occur on the server? Which
controls are you using in the menu? If I'm following that correctly then
this architecture doesn't make sense to me since navigation itself is also
really a client side operation in that the client requests the page to
navigate to and the server merely provides it back to the client.

If you're doing some type of processing then calling Response.Redirect() or
Server.Transfer(), couldn't you create a redirection page that performs the
appropriate processing then redirects and link to the redirection page? If
you're not doing any processing other than a redirect you should just link
directly to the desired file. In either case, just set the target attribute
to the appropriate frame.

You could probably also get away with setting the target attribute of the
form to the desired frame...

If you're still against using a client based mechanism, then your option
becomes convert the menu to a WebControl and ditch the frames.

Anything you can do to reduce the number of round trips to the server will
improve your application's performance. Doing a postback then
Response.Redirect() results in two round trips. Requesting a redirection
page and calling Response.Redirect results in two round trips. Linking to
the page directly or using Server.Transfer() results in one round trip.

"Ohad Young" <ohadyn@.bgumail.bgu.ac.il> wrote in message
news:O4PqPK2XEHA.3044@.TK2MSFTNGP09.phx.gbl...
> Hi,
> I have a frameset page that contains two frames:
> 1. the first frame, an aspx page, contains a menu for navigating in the
> website.
> 2. the second frame contains content, pdf, html or other aspx files
> The problem is that the menu activates a server-side methods when the user
> clicks on one of the menu items.
> However, from the server side I cannot control in which frame the content
> will appears, it will always be in the menu frame itself.
> So, how can I control from a server side function the frame to display the
> content?
> Is it even possible?
> If not, how to avoid it without using client-based menus?
> Thanks, Ohad
> --
> Ohad Young
> Medical Informatics Research Center
> Ben Gurion University
> Information System Eng
> Office Phone: 972-8-6477160
> Cellular Phone: 972-54-518301
> E-Mail: ohadyn@.bgumail.bgu.ac.il
hi ohad, did you find the answer?
i have the same problem as well.
10x, alon.

************************************************** ********************
Sent via Fuzzy Software @. http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...