|
.net
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Function from aspxHow 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 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 -- Show quoteHide quoteDan "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 > 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 >> > > 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 -- Show quoteHide quoteDan "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 >>> >> >> > > 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 >>>> >>> >>> >> >> > > Sounds like a fair enough method.
-- Show quoteHide quoteDan "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 >>>>> >>>> >>>> >>> >>> >> >> > > 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
Other interesting topics
WebResource.axd request causing errors
2.0 Custom Membership Provider! Calendar Control New to ASP.NET 2.0 ASP.NET process identity does not have read permissions to the global assembly cache Help with inline code? Custom IIdentity w/ FormsAuthentication Video in ASPX Query Data via SMS What is ASPNETDB.MDF used for? |
|||||||||||||||||||||||