Results 1 to 14 of 14

Thread: [RESOLVED] help needed in implement the concept using javascript

  1. #1

    Thread Starter
    Fanatic Member karthikeyan's Avatar
    Join Date
    Oct 2005
    Location
    inside .net
    Posts
    919

    Resolved [RESOLVED] help needed in implement the concept using javascript

    Hi,

    Here is my code

    Code:
     <ItemTemplate>
    <asp:Label runat="server" Width="80%" Text='<%# DataBinder.Eval(Container.DataItem, "Name") %>' ID="lblName"></asp:Label>
    
     <asp:LinkButton ID="btnDelete" runat="server" Text="Delete" OnClientClick="return Confirm(event, 'Confirm', 'Delete Page Layout', message, 'Delete');"></asp:LinkButton>
    
     </ItemTemplate>
    i have seprate javascript function called Confirm. So this code is working fine for me.

    i have another requirement that i need to append the label text in this javascript function.
    for example in this javascript function i am passing "Delete Page Layout" as message. so i need to append the label text with this message.

    for example

    if the label text is vbforums then my message should be "Delete Page Layout vbforums?". so please help me to append the label text in this javascript message parameter.

    i have tried like this

    Code:
    <asp:LinkButton ID="btnDelete" runat="server" Text="Delete" OnClientClick="return Confirm(event, 'Confirm', 'Delete Page Layout + '<%# DataBinder.Eval(Container.DataItem, "Name") %>', message, 'Delete');"></asp:LinkButton>
    but it is not working. and one important is this should be done in aspx side only. i should not go for code behind.so please help me to achieve this .k indly give me some sample to do this pease.
    Loving dotnet

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: help needed in implement the concept using javascript

    Why should you not go into the codebehind and what exactly makes this 'avoidance' so important? Or are you being lazy? That's the most common reason when someone wants to avoid the codebehind - they're simply lazy and that's right, I ain't afraid to say it

    If the code above isn't working for you, you should tell us what exactly is happening. Come on karth, you've been on these forums long enough to know the drill. My guess would be that your quotes and double quotes are not mixing right, but only your details can help confirm it.

  3. #3

    Thread Starter
    Fanatic Member karthikeyan's Avatar
    Join Date
    Oct 2005
    Location
    inside .net
    Posts
    919

    Re: help needed in implement the concept using javascript

    Hi mendhak,

    the error i am getting is The server tag is not well formed.

    code i used :

    Code:
    <asp:LinkButton ID="btnDelete" runat="server" Text="Delete" OnClientClick="return Confirm(event, 'Confirm', 'Delete Page Layout'+"<%# DataBinder.Eval(Container.DataItem, "WebPartCategoryName") %>",'message', 'Delete');" ></asp:LinkButton>

    please help me in this friend
    Loving dotnet

  4. #4
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: help needed in implement the concept using javascript

    Hey,

    Can you not set this value on the Load Event of the page rather than in the aspx markup? It would be far easier, and a better way, to do this, rather than trying to create it using Server Side Tags in the aspx page.

    Gary

  5. #5
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: help needed in implement the concept using javascript

    I have little or no experience with this but you can try

    Code:
    "return Confirm(event, 'Confirm', 'Delete Page Layout'+'<&#37;# DataBinder.Eval(Container.DataItem, \"WebPartCategoryName\") %>','message', 'Delete');"
    Or someone with more knowledge of this can help. I'm sure gep loves inline code.

  6. #6
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: help needed in implement the concept using javascript

    Hey,

    I used to use inline code all the time, but after reading your article, I was converted

    Although, still been reading about the ASP.Net MVC Framework, and it seems to love inline code!!

    Gary

  7. #7

    Thread Starter
    Fanatic Member karthikeyan's Avatar
    Join Date
    Oct 2005
    Location
    inside .net
    Posts
    919

    Re: help needed in implement the concept using javascript

    Hi Mendhak and Gary thanks for the reply. actully i got the solution.

    Code:
    OnClientClick='<%# String.Format( "return Confirm(event,\"{0}\",\"{1}\",\"{2}\",\"{3}\");" , "Confirm", "Delete Page Layout ", "Are you sure you want to delete " + Eval("WebPartCategoryName") + " ?","Delete")%>'
    this does my requirement.

    mendhak,

    i will try yours and will get back to you.

    why i am afraid of doing this in server side is if you look the paramenters there is a parameter called event. so rest of the other parameters we can send it from code behind, but what about event ? thats why i tried to do this in line.

    doubt:

    can it be possible to pass the event parameter from code behind?
    my script as follows:

    Code:
    window.Confirm = function(mozEvent, prompt, title, message, buttonName)
    {
       // some other code here
    }
    please any sugestions
    Loving dotnet

  8. #8
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: help needed in implement the concept using javascript

    Hey,

    What I was talking about was using the ItemDataBound event of the control that you are using to set the OnClientClick property of the LinkButton, rather than using a Server Side Tag in the ASPX page. That will still maintain the client side functionality that you are after, but it will prevent you having to "hack" the Server Side Tag to get it to work the way you want it.

    Gary

  9. #9

    Thread Starter
    Fanatic Member karthikeyan's Avatar
    Join Date
    Oct 2005
    Location
    inside .net
    Posts
    919

    Re: help needed in implement the concept using javascript

    hi Gary,

    i understood what you are saying, my first try was using item databound event of the link button only. but that was failed. because i am not to send event. the red marked.

    Code:
    OnClientClick='<%# String.Format( "return Confirm(event,\"{0}\",\"{1}\",\"{2}\",\"{3}\");" , "Confirm", "Delete Page Layout ", "Are you sure you want to delete " + Eval("WebPartCategoryName") + " ?","Delete")%>'
    this event will be checked in the javascript function. so that i hav tried using inline itself.

    any pointers please
    Loving dotnet

  10. #10
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: help needed in implement the concept using javascript

    Hey,

    The OnClientClick event is just a string value that you can set in the ItemDataBound event:

    http://msdn.microsoft.com/en-us/libr...ck(VS.80).aspx

    So I don't see why you can't just do what you are doing by writing "event" into the string that you set as the OnClientClick property.

    I could be missing something though.

    Gary

  11. #11

    Thread Starter
    Fanatic Member karthikeyan's Avatar
    Join Date
    Oct 2005
    Location
    inside .net
    Posts
    919

    Re: help needed in implement the concept using javascript

    thanks for the information sharing gary. cheers
    Loving dotnet

  12. #12
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: [RESOLVED] help needed in implement the concept using javascript

    Not a problem at all.

    Did you try the method that I suggested? Out of curiousity, did this work, or are you sticking with the String.Format in the Server Side Tag?

    Gary

  13. #13
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [RESOLVED] help needed in implement the concept using javascript

    The 'event' is something that the javascript will understand. It's like asking "If I write alert('hello'); from the codebehind, will javascript understand the alert()? Yes, it will. All you're doing is generating the javascript and writing it to the HTML source from the codebehind.

  14. #14

    Thread Starter
    Fanatic Member karthikeyan's Avatar
    Join Date
    Oct 2005
    Location
    inside .net
    Posts
    919

    Smile Re: [RESOLVED] help needed in implement the concept using javascript

    Gary,

    i have tried with appending the JavaScript with link button in item databound, it is not firing the java script when i click the button. so i have used the string.format, because today i have release. so this requirement is very important and no time also .so no time to do R & D. so used string.format in the inline itself. but i will try this once i get time.

    Mendhak,

    you are right, i understood this can be written in server side. i will try this surely.

    Thanks lot friends.
    Loving dotnet

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width