473,378 Members | 1,541 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Function from aspx

How can you call function from aspx page?

For example:

button on aspx page:
<asp:button Visible="<% =funcVisible()%>" id="btnNew"
Runat="server"></asp:button>
code behind function:

Public Function funcVisible() As Boolean
funcVisible = False
End Function

This won't work.

Regards,S
Jan 6 '06 #1
6 1924
Dan
I presume your an asp man and not aspx. In aspx you would do it by assigning
an event to the button or do this

<asp:button onclick=doClick id="btnNew" Runat="server"></asp:button>

and in your code behind file

public void doClick()
{
//do something
}

I would set the visible setting in the codebehind file too. It is much
better to separate the code from the design which is the greatest part of
the .net era.

so in your page load do btnNew.Visible = false;

Hope that helps

--
Dan
"SimonZ" <si*********@studio-moderna.com> wrote in message
news:OD*************@TK2MSFTNGP09.phx.gbl...
How can you call function from aspx page?

For example:

button on aspx page:
<asp:button Visible="<% =funcVisible()%>" id="btnNew"
Runat="server"></asp:button>
code behind function:

Public Function funcVisible() As Boolean
funcVisible = False
End Function

This won't work.

Regards,S

Jan 6 '06 #2
Hi, Dan

I know I can set everything in code behind.

But I would like to know if it's possible to set the visible property of
some button to call the function from aspx page.

If my button is in some data component(dataGrid for example) it would work
by adding hash sign:

visible="<%# funcVisible()%>"

but if I remove # sign (button is not in data component) it won't work.

Regards,S
"Dan" <dv*******@aol.com> wrote in message
news:uI**************@TK2MSFTNGP10.phx.gbl...
I presume your an asp man and not aspx. In aspx you would do it by
assigning an event to the button or do this

<asp:button onclick=doClick id="btnNew" Runat="server"></asp:button>

and in your code behind file

public void doClick()
{
//do something
}

I would set the visible setting in the codebehind file too. It is much
better to separate the code from the design which is the greatest part of
the .net era.

so in your page load do btnNew.Visible = false;

Hope that helps

--
Dan
"SimonZ" <si*********@studio-moderna.com> wrote in message
news:OD*************@TK2MSFTNGP09.phx.gbl...
How can you call function from aspx page?

For example:

button on aspx page:
<asp:button Visible="<% =funcVisible()%>" id="btnNew"
Runat="server"></asp:button>
code behind function:

Public Function funcVisible() As Boolean
funcVisible = False
End Function

This won't work.

Regards,S


Jan 6 '06 #3
Dan
Hi Simon,

Can i ask why you would ever want to call a function by using a property? (i
dont think it is possible but i have never tried) . There is probably a
better solution to your problem than this method?

Let me know

--
Dan
"SimonZ" <si*********@studio-moderna.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi, Dan

I know I can set everything in code behind.

But I would like to know if it's possible to set the visible property of
some button to call the function from aspx page.

If my button is in some data component(dataGrid for example) it would work
by adding hash sign:

visible="<%# funcVisible()%>"

but if I remove # sign (button is not in data component) it won't work.

Regards,S
"Dan" <dv*******@aol.com> wrote in message
news:uI**************@TK2MSFTNGP10.phx.gbl...
I presume your an asp man and not aspx. In aspx you would do it by
assigning an event to the button or do this

<asp:button onclick=doClick id="btnNew" Runat="server"></asp:button>

and in your code behind file

public void doClick()
{
//do something
}

I would set the visible setting in the codebehind file too. It is much
better to separate the code from the design which is the greatest part of
the .net era.

so in your page load do btnNew.Visible = false;

Hope that helps

--
Dan
"SimonZ" <si*********@studio-moderna.com> wrote in message
news:OD*************@TK2MSFTNGP09.phx.gbl...
How can you call function from aspx page?

For example:

button on aspx page:
<asp:button Visible="<% =funcVisible()%>" id="btnNew"
Runat="server"></asp:button>
code behind function:

Public Function funcVisible() As Boolean
funcVisible = False
End Function

This won't work.

Regards,S



Jan 6 '06 #4
Hi, Dan

it's just curiosity, it's possible to do other way.

What about this example:

I have dataGrid with ItemTemplate and editItem template.

For some users I would like that they see editItem template and change
values, for other users I would like that edit item template is the same as
item template for some items.

Can you do that in code behind, something like:

If user<>"admin" then
datagrid.Item1.editItemTemplate=ItemTemplate
datagrid.Item3.editItemTemplate=ItemTemplate
end if

Any idea?

Regards,
S
"Dan" <dv*******@aol.com> wrote in message
news:uf**************@TK2MSFTNGP11.phx.gbl...
Hi Simon,

Can i ask why you would ever want to call a function by using a property?
(i dont think it is possible but i have never tried) . There is probably a
better solution to your problem than this method?

Let me know

--
Dan
"SimonZ" <si*********@studio-moderna.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi, Dan

I know I can set everything in code behind.

But I would like to know if it's possible to set the visible property of
some button to call the function from aspx page.

If my button is in some data component(dataGrid for example) it would
work by adding hash sign:

visible="<%# funcVisible()%>"

but if I remove # sign (button is not in data component) it won't work.

Regards,S
"Dan" <dv*******@aol.com> wrote in message
news:uI**************@TK2MSFTNGP10.phx.gbl...
I presume your an asp man and not aspx. In aspx you would do it by
assigning an event to the button or do this

<asp:button onclick=doClick id="btnNew" Runat="server"></asp:button>

and in your code behind file

public void doClick()
{
//do something
}

I would set the visible setting in the codebehind file too. It is much
better to separate the code from the design which is the greatest part
of the .net era.

so in your page load do btnNew.Visible = false;

Hope that helps

--
Dan
"SimonZ" <si*********@studio-moderna.com> wrote in message
news:OD*************@TK2MSFTNGP09.phx.gbl...
How can you call function from aspx page?

For example:

button on aspx page:
<asp:button Visible="<% =funcVisible()%>" id="btnNew"
Runat="server"></asp:button>
code behind function:

Public Function funcVisible() As Boolean
funcVisible = False
End Function

This won't work.

Regards,S



Jan 6 '06 #5
Dan
Sounds like a fair enough method.

--
Dan
"SimonZ" <si*********@studio-moderna.com> wrote in message
news:uh*************@TK2MSFTNGP12.phx.gbl...
Hi, Dan

it's just curiosity, it's possible to do other way.

What about this example:

I have dataGrid with ItemTemplate and editItem template.

For some users I would like that they see editItem template and change
values, for other users I would like that edit item template is the same
as item template for some items.

Can you do that in code behind, something like:

If user<>"admin" then
datagrid.Item1.editItemTemplate=ItemTemplate
datagrid.Item3.editItemTemplate=ItemTemplate
end if

Any idea?

Regards,
S
"Dan" <dv*******@aol.com> wrote in message
news:uf**************@TK2MSFTNGP11.phx.gbl...
Hi Simon,

Can i ask why you would ever want to call a function by using a property?
(i dont think it is possible but i have never tried) . There is probably
a better solution to your problem than this method?

Let me know

--
Dan
"SimonZ" <si*********@studio-moderna.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi, Dan

I know I can set everything in code behind.

But I would like to know if it's possible to set the visible property of
some button to call the function from aspx page.

If my button is in some data component(dataGrid for example) it would
work by adding hash sign:

visible="<%# funcVisible()%>"

but if I remove # sign (button is not in data component) it won't work.

Regards,S
"Dan" <dv*******@aol.com> wrote in message
news:uI**************@TK2MSFTNGP10.phx.gbl...
I presume your an asp man and not aspx. In aspx you would do it by
assigning an event to the button or do this

<asp:button onclick=doClick id="btnNew" Runat="server"></asp:button>

and in your code behind file

public void doClick()
{
//do something
}

I would set the visible setting in the codebehind file too. It is much
better to separate the code from the design which is the greatest part
of the .net era.

so in your page load do btnNew.Visible = false;

Hope that helps

--
Dan
"SimonZ" <si*********@studio-moderna.com> wrote in message
news:OD*************@TK2MSFTNGP09.phx.gbl...
> How can you call function from aspx page?
>
> For example:
>
> button on aspx page:
> <asp:button Visible="<% =funcVisible()%>" id="btnNew"
> Runat="server"></asp:button>
>
>
> code behind function:
>
> Public Function funcVisible() As Boolean
> funcVisible = False
> End Function
>
> This won't work.
>
> Regards,S
>



Jan 6 '06 #6

I know people jump the example sometimes, not the concept.

I do this, and legimately I feel.

I store my userid's and guids. UserUUID in my example.
HTML doesn't like the hyphens' in the Guid's, when setting the id's of
the aspx controls.

So I strip them out.

My code is in a Repeater, (thus the Eval), but you should be able to
strip it out.
<div id='d<%# GuidSafeName(Convert.ToString(Eval("UserUUID"))) %>'>

</div>


code behind
public string GuidSafeName(string uuid)
{
return uuid.Replace("-", "");
}
Also.
Play with the double and single quotes. Sometimes that'll kill you.

See how in my aspx code, the id for div .. is in a single quote.

...

SimonZ wrote:
How can you call function from aspx page?

For example:

button on aspx page:
<asp:button Visible="<% =funcVisible()%>" id="btnNew"
Runat="server"></asp:button>
code behind function:

Public Function funcVisible() As Boolean
funcVisible = False
End Function

This won't work.

Regards,S


Jan 6 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Mark Kurten | last post by:
in the visual studio .NET samples that come with the product, why do javascript functions all have the parameters below. Even though, the event (like Onclick) which is calling it doesn't have any...
2
by: moondaddy | last post by:
I'm using vb.net and have an aspx page where I want to call a function in the code behind to do something on the backend and I want to call this function from a jscript function in the aspx page. ...
7
by: Tiraman | last post by:
Hi , I have 3 files , middle.aspx file include the header.aspx and footer.aspx files . in each of the include files there is a function and from some reason the call to the Footer() function...
1
by: D. Shane Fowlkes | last post by:
Hello All. I keep asking for help with this on the www.asp.net forums and nobody seems to be able to help. What I'm trying to accomplish is very simple. I simply want to create a Hyperlink...
10
by: bienwell | last post by:
Hi, I have a question about file included in ASP.NET. I have a file that includes all the Sub functions (e.g FileFunct.vb). One of the functions in this file is : Sub TestFunct(ByVal...
3
by: Mike Weathery | last post by:
Hi all I am using the following function in a text entry box: function goToTV() { location.href="http://www.tvguide.com" + "/search/index.aspx?keyword=" + document.search.q.value; return...
6
by: RandomElle | last post by:
Hi there I'm hoping someone can help me out with the use of the Eval function. I am using Access2003 under WinXP Pro. I can successfully use the Eval function and get it to call any function with...
1
by: john20 | last post by:
Hi All, I am having a problem with accesing function in the page. i have a page say user.aspx in the page load method i am calling function to validate the user. it works fine when single...
23
by: Stewart Berman | last post by:
I am trying to develop a wrapper class for the Windows API functions in Visual Studio 2008: GetOpenFileName GetSaveFileName I put together a starter class: using System; using...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.