Home All Groups Group Topic Archive Search About
Author
6 Jan 2006 8:35 AM
SimonZ
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

Author
6 Jan 2006 8:46 AM
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
Show quoteHide quote
"SimonZ" <simon.zu***@studio-moderna.com> wrote in message
news:ODJG5wpEGHA.716@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
>
Are all your drivers up to date? click for free checkup

Author
6 Jan 2006 8:56 AM
SimonZ
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


Show quoteHide quote
"Dan" <dvazan***@aol.com> wrote in message
news:uIJJx2pEGHA.3104@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" <simon.zu***@studio-moderna.com> wrote in message
> news:ODJG5wpEGHA.716@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
>>
>
>
Author
6 Jan 2006 9:21 AM
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
Show quoteHide quote
"SimonZ" <simon.zu***@studio-moderna.com> wrote in message
news:%23EFnJ8pEGHA.2196@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" <dvazan***@aol.com> wrote in message
> news:uIJJx2pEGHA.3104@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" <simon.zu***@studio-moderna.com> wrote in message
>> news:ODJG5wpEGHA.716@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
>>>
>>
>>
>
>
Author
6 Jan 2006 9:34 AM
SimonZ
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


Show quoteHide quote
"Dan" <dvazan***@aol.com> wrote in message
news:ufwDWKqEGHA.1028@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" <simon.zu***@studio-moderna.com> wrote in message
> news:%23EFnJ8pEGHA.2196@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" <dvazan***@aol.com> wrote in message
>> news:uIJJx2pEGHA.3104@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" <simon.zu***@studio-moderna.com> wrote in message
>>> news:ODJG5wpEGHA.716@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
>>>>
>>>
>>>
>>
>>
>
>
Author
6 Jan 2006 9:54 AM
Dan
Sounds like a fair enough method.

--
Dan
Show quoteHide quote
"SimonZ" <simon.zu***@studio-moderna.com> wrote in message
news:uhYKvRqEGHA.740@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" <dvazan***@aol.com> wrote in message
> news:ufwDWKqEGHA.1028@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" <simon.zu***@studio-moderna.com> wrote in message
>> news:%23EFnJ8pEGHA.2196@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" <dvazan***@aol.com> wrote in message
>>> news:uIJJx2pEGHA.3104@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" <simon.zu***@studio-moderna.com> wrote in message
>>>> news:ODJG5wpEGHA.716@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
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>
Author
6 Jan 2006 11:09 PM
sloan
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:
Show quoteHide quote
> 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

Bookmark and Share