onClientClick does not work correctly after deploying

Discussion in 'ASP .Net' started by cyrus, Sep 2, 2008.

  1. cyrus

    cyrus Guest

    Hi everybody,

    I have created a simple web form which contains a repeater. every item of
    the repeater has a button to delete the tiem.

    my web form uses Resource files to globalizing the form (multiLanguage). the
    value of the resource string is saved in a asp:hidden control to be used
    later in a javascript function, so in the following code ConfirmMessage is a
    asp:hidden control which saves the value of the properties of the resource
    files.

    So the value of ConfirmMessage is a confirm message from Resource files in 4
    languages which will be showen when a client click on the RemoveBtn to delete
    an item.



    in developing environment everything works good and i deploy it to
    production. within the production machine I browse to my site
    (http://mydomain.com) and here everything works good, I get the confirm
    message and when I click on Cancel it nothing happen (the item is not
    deleted). But the problem is when I browse to production from another machine
    it removes the item even when I click Cancel. it seems the javascript does
    not works at all. it do a reload and it seems to go in to the onClick event.

    Thank you for any help.


    here is my code:

    asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1"
    Runat="Server">

    <script language="javascript" type="text/javascript">

    function ShowConfirmDelete() {
    var theMessage =
    document.getElementById('<%=ConfirmMessage.ClientID%>').value;

    return confirm(theMessage);
    }

    </script>

    <asp:Repeater ID="DataList1" runat="server" DataSourceID="SqlDataSource1" >

    <ItemTemplate>

    asp:Label ID="itemdateLabel" runat="server" Text='<%#
    Eval("CreatedDate","{0}") %>' />

    <asp:Button ID="RemoveBtn" runat="server" Text="delete"
    OnClick="RemoveBtn_Click" OnClientClick="return ShowConfirmDelete();" />

    </ItemTemplate>

    </asp:Repeater>

    </asp:Content>
    cyrus, Sep 2, 2008
    #1
    1. Advertising

  2. cyrus

    Jeff Dillon Guest

    "cyrus" <> wrote in message
    news:...
    > Hi everybody,
    >
    > I have created a simple web form which contains a repeater. every item of
    > the repeater has a button to delete the tiem.
    >
    > my web form uses Resource files to globalizing the form (multiLanguage).
    > the
    > value of the resource string is saved in a asp:hidden control to be used
    > later in a javascript function, so in the following code ConfirmMessage is
    > a
    > asp:hidden control which saves the value of the properties of the resource
    > files.
    >
    > So the value of ConfirmMessage is a confirm message from Resource files in
    > 4
    > languages which will be showen when a client click on the RemoveBtn to
    > delete
    > an item.
    >
    >
    >
    > in developing environment everything works good and i deploy it to
    > production. within the production machine I browse to my site
    > (http://mydomain.com) and here everything works good, I get the confirm
    > message and when I click on Cancel it nothing happen (the item is not
    > deleted). But the problem is when I browse to production from another
    > machine
    > it removes the item even when I click Cancel. it seems the javascript does
    > not works at all. it do a reload and it seems to go in to the onClick
    > event.
    >
    > Thank you for any help.
    >
    >
    > here is my code:
    >
    > asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1"
    > Runat="Server">
    >
    > <script language="javascript" type="text/javascript">
    >
    > function ShowConfirmDelete() {
    > var theMessage =
    > document.getElementById('<%=ConfirmMessage.ClientID%>').value;
    >
    > return confirm(theMessage);
    > }
    >
    > </script>
    >
    > <asp:Repeater ID="DataList1" runat="server" DataSourceID="SqlDataSource1"
    > >

    >
    > <ItemTemplate>
    >
    > asp:Label ID="itemdateLabel" runat="server" Text='<%#
    > Eval("CreatedDate","{0}") %>' />
    >
    > <asp:Button ID="RemoveBtn" runat="server" Text="delete"
    > OnClick="RemoveBtn_Click" OnClientClick="return ShowConfirmDelete();" />
    >
    > </ItemTemplate>
    >
    > </asp:Repeater>
    >
    > </asp:Content>
    >
    >


    View Source
    Jeff Dillon, Sep 2, 2008
    #2
    1. Advertising

  3. cyrus

    cyrus Guest

    what do you mean??

    "Jeff Dillon" wrote:

    > "cyrus" <> wrote in message
    > news:...
    > > Hi everybody,
    > >
    > > I have created a simple web form which contains a repeater. every item of
    > > the repeater has a button to delete the tiem.
    > >
    > > my web form uses Resource files to globalizing the form (multiLanguage).
    > > the
    > > value of the resource string is saved in a asp:hidden control to be used
    > > later in a javascript function, so in the following code ConfirmMessage is
    > > a
    > > asp:hidden control which saves the value of the properties of the resource
    > > files.
    > >
    > > So the value of ConfirmMessage is a confirm message from Resource files in
    > > 4
    > > languages which will be showen when a client click on the RemoveBtn to
    > > delete
    > > an item.
    > >
    > >
    > >
    > > in developing environment everything works good and i deploy it to
    > > production. within the production machine I browse to my site
    > > (http://mydomain.com) and here everything works good, I get the confirm
    > > message and when I click on Cancel it nothing happen (the item is not
    > > deleted). But the problem is when I browse to production from another
    > > machine
    > > it removes the item even when I click Cancel. it seems the javascript does
    > > not works at all. it do a reload and it seems to go in to the onClick
    > > event.
    > >
    > > Thank you for any help.
    > >
    > >
    > > here is my code:
    > >
    > > asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1"
    > > Runat="Server">
    > >
    > > <script language="javascript" type="text/javascript">
    > >
    > > function ShowConfirmDelete() {
    > > var theMessage =
    > > document.getElementById('<%=ConfirmMessage.ClientID%>').value;
    > >
    > > return confirm(theMessage);
    > > }
    > >
    > > </script>
    > >
    > > <asp:Repeater ID="DataList1" runat="server" DataSourceID="SqlDataSource1"
    > > >

    > >
    > > <ItemTemplate>
    > >
    > > asp:Label ID="itemdateLabel" runat="server" Text='<%#
    > > Eval("CreatedDate","{0}") %>' />
    > >
    > > <asp:Button ID="RemoveBtn" runat="server" Text="delete"
    > > OnClick="RemoveBtn_Click" OnClientClick="return ShowConfirmDelete();" />
    > >
    > > </ItemTemplate>
    > >
    > > </asp:Repeater>
    > >
    > > </asp:Content>
    > >
    > >

    >
    > View Source
    >
    >
    >
    cyrus, Sep 3, 2008
    #3
  4. cyrus

    Jeff Dillon Guest

    "cyrus" <> wrote in message
    news:...
    > what do you mean??
    >
    > "Jeff Dillon" wrote:
    >
    >> "cyrus" <> wrote in message
    >> news:...
    >> > Hi everybody,
    >> >
    >> > I have created a simple web form which contains a repeater. every item
    >> > of
    >> > the repeater has a button to delete the tiem.
    >> >
    >> > my web form uses Resource files to globalizing the form
    >> > (multiLanguage).
    >> > the
    >> > value of the resource string is saved in a asp:hidden control to be
    >> > used
    >> > later in a javascript function, so in the following code ConfirmMessage
    >> > is
    >> > a
    >> > asp:hidden control which saves the value of the properties of the
    >> > resource
    >> > files.
    >> >
    >> > So the value of ConfirmMessage is a confirm message from Resource files
    >> > in
    >> > 4
    >> > languages which will be showen when a client click on the RemoveBtn to
    >> > delete
    >> > an item.
    >> >
    >> >
    >> >
    >> > in developing environment everything works good and i deploy it to
    >> > production. within the production machine I browse to my site
    >> > (http://mydomain.com) and here everything works good, I get the confirm
    >> > message and when I click on Cancel it nothing happen (the item is not
    >> > deleted). But the problem is when I browse to production from another
    >> > machine
    >> > it removes the item even when I click Cancel. it seems the javascript
    >> > does
    >> > not works at all. it do a reload and it seems to go in to the onClick
    >> > event.
    >> >
    >> > Thank you for any help.
    >> >
    >> >
    >> > here is my code:
    >> >
    >> > asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1"
    >> > Runat="Server">
    >> >
    >> > <script language="javascript" type="text/javascript">
    >> >
    >> > function ShowConfirmDelete() {
    >> > var theMessage =
    >> > document.getElementById('<%=ConfirmMessage.ClientID%>').value;
    >> >
    >> > return confirm(theMessage);
    >> > }
    >> >
    >> > </script>
    >> >
    >> > <asp:Repeater ID="DataList1" runat="server"
    >> > DataSourceID="SqlDataSource1"
    >> > >
    >> >
    >> > <ItemTemplate>
    >> >
    >> > asp:Label ID="itemdateLabel" runat="server" Text='<%#
    >> > Eval("CreatedDate","{0}") %>' />
    >> >
    >> > <asp:Button ID="RemoveBtn" runat="server" Text="delete"
    >> > OnClick="RemoveBtn_Click" OnClientClick="return ShowConfirmDelete();"
    >> > />
    >> >
    >> > </ItemTemplate>
    >> >
    >> > </asp:Repeater>
    >> >
    >> > </asp:Content>
    >> >
    >> >

    >>
    >> View Source
    >>
    >>
    >>


    Are you familiar with View Source in IE? Look at the page after it renders,
    and look for differences.
    Jeff Dillon, Sep 4, 2008
    #4
  5. cyrus

    cyrus Guest

    Thank you again,

    Actually I dont familiar with view soruce and dont understan, i am going to
    google about it.


    "Jeff Dillon" wrote:

    >
    > "cyrus" <> wrote in message
    > news:...
    > > what do you mean??
    > >
    > > "Jeff Dillon" wrote:
    > >
    > >> "cyrus" <> wrote in message
    > >> news:...
    > >> > Hi everybody,
    > >> >
    > >> > I have created a simple web form which contains a repeater. every item
    > >> > of
    > >> > the repeater has a button to delete the tiem.
    > >> >
    > >> > my web form uses Resource files to globalizing the form
    > >> > (multiLanguage).
    > >> > the
    > >> > value of the resource string is saved in a asp:hidden control to be
    > >> > used
    > >> > later in a javascript function, so in the following code ConfirmMessage
    > >> > is
    > >> > a
    > >> > asp:hidden control which saves the value of the properties of the
    > >> > resource
    > >> > files.
    > >> >
    > >> > So the value of ConfirmMessage is a confirm message from Resource files
    > >> > in
    > >> > 4
    > >> > languages which will be showen when a client click on the RemoveBtn to
    > >> > delete
    > >> > an item.
    > >> >
    > >> >
    > >> >
    > >> > in developing environment everything works good and i deploy it to
    > >> > production. within the production machine I browse to my site
    > >> > (http://mydomain.com) and here everything works good, I get the confirm
    > >> > message and when I click on Cancel it nothing happen (the item is not
    > >> > deleted). But the problem is when I browse to production from another
    > >> > machine
    > >> > it removes the item even when I click Cancel. it seems the javascript
    > >> > does
    > >> > not works at all. it do a reload and it seems to go in to the onClick
    > >> > event.
    > >> >
    > >> > Thank you for any help.
    > >> >
    > >> >
    > >> > here is my code:
    > >> >
    > >> > asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1"
    > >> > Runat="Server">
    > >> >
    > >> > <script language="javascript" type="text/javascript">
    > >> >
    > >> > function ShowConfirmDelete() {
    > >> > var theMessage =
    > >> > document.getElementById('<%=ConfirmMessage.ClientID%>').value;
    > >> >
    > >> > return confirm(theMessage);
    > >> > }
    > >> >
    > >> > </script>
    > >> >
    > >> > <asp:Repeater ID="DataList1" runat="server"
    > >> > DataSourceID="SqlDataSource1"
    > >> > >
    > >> >
    > >> > <ItemTemplate>
    > >> >
    > >> > asp:Label ID="itemdateLabel" runat="server" Text='<%#
    > >> > Eval("CreatedDate","{0}") %>' />
    > >> >
    > >> > <asp:Button ID="RemoveBtn" runat="server" Text="delete"
    > >> > OnClick="RemoveBtn_Click" OnClientClick="return ShowConfirmDelete();"
    > >> > />
    > >> >
    > >> > </ItemTemplate>
    > >> >
    > >> > </asp:Repeater>
    > >> >
    > >> > </asp:Content>
    > >> >
    > >> >
    > >>
    > >> View Source
    > >>
    > >>
    > >>

    >
    > Are you familiar with View Source in IE? Look at the page after it renders,
    > and look for differences.
    >
    >
    >
    cyrus, Sep 5, 2008
    #5
  6. cyrus

    Jeff Dillon Guest

    "cyrus" <> wrote in message
    news:...
    >
    > Thank you again,
    >
    > Actually I dont familiar with view soruce and dont understan, i am going
    > to
    > google about it.
    >
    >
    > "Jeff Dillon" wrote:
    >
    >>
    >> "cyrus" <> wrote in message
    >> news:...
    >> > what do you mean??
    >> >
    >> > "Jeff Dillon" wrote:
    >> >
    >> >> "cyrus" <> wrote in message
    >> >> news:...
    >> >> > Hi everybody,
    >> >> >
    >> >> > I have created a simple web form which contains a repeater. every
    >> >> > item
    >> >> > of
    >> >> > the repeater has a button to delete the tiem.
    >> >> >
    >> >> > my web form uses Resource files to globalizing the form
    >> >> > (multiLanguage).
    >> >> > the
    >> >> > value of the resource string is saved in a asp:hidden control to be
    >> >> > used
    >> >> > later in a javascript function, so in the following code
    >> >> > ConfirmMessage
    >> >> > is
    >> >> > a
    >> >> > asp:hidden control which saves the value of the properties of the
    >> >> > resource
    >> >> > files.
    >> >> >
    >> >> > So the value of ConfirmMessage is a confirm message from Resource
    >> >> > files
    >> >> > in
    >> >> > 4
    >> >> > languages which will be showen when a client click on the RemoveBtn
    >> >> > to
    >> >> > delete
    >> >> > an item.
    >> >> >
    >> >> >
    >> >> >
    >> >> > in developing environment everything works good and i deploy it to
    >> >> > production. within the production machine I browse to my site
    >> >> > (http://mydomain.com) and here everything works good, I get the
    >> >> > confirm
    >> >> > message and when I click on Cancel it nothing happen (the item is
    >> >> > not
    >> >> > deleted). But the problem is when I browse to production from
    >> >> > another
    >> >> > machine
    >> >> > it removes the item even when I click Cancel. it seems the
    >> >> > javascript
    >> >> > does
    >> >> > not works at all. it do a reload and it seems to go in to the
    >> >> > onClick
    >> >> > event.
    >> >> >
    >> >> > Thank you for any help.
    >> >> >
    >> >> >
    >> >> > here is my code:
    >> >> >
    >> >> > asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1"
    >> >> > Runat="Server">
    >> >> >
    >> >> > <script language="javascript" type="text/javascript">
    >> >> >
    >> >> > function ShowConfirmDelete() {
    >> >> > var theMessage =
    >> >> > document.getElementById('<%=ConfirmMessage.ClientID%>').value;
    >> >> >
    >> >> > return confirm(theMessage);
    >> >> > }
    >> >> >
    >> >> > </script>
    >> >> >
    >> >> > <asp:Repeater ID="DataList1" runat="server"
    >> >> > DataSourceID="SqlDataSource1"
    >> >> > >
    >> >> >
    >> >> > <ItemTemplate>
    >> >> >
    >> >> > asp:Label ID="itemdateLabel" runat="server" Text='<%#
    >> >> > Eval("CreatedDate","{0}") %>' />
    >> >> >
    >> >> > <asp:Button ID="RemoveBtn" runat="server" Text="delete"
    >> >> > OnClick="RemoveBtn_Click" OnClientClick="return
    >> >> > ShowConfirmDelete();"
    >> >> > />
    >> >> >
    >> >> > </ItemTemplate>
    >> >> >
    >> >> > </asp:Repeater>
    >> >> >
    >> >> > </asp:Content>
    >> >> >
    >> >> >
    >> >>
    >> >> View Source
    >> >>
    >> >>
    >> >>

    >>
    >> Are you familiar with View Source in IE? Look at the page after it
    >> renders,
    >> and look for differences.
    >>
    >>
    >>


    If you are using Internet Explorer, right click on the page, and choose View
    Source. It will show all the HTML markup and Javascript too. It sounds like
    your Javascript isn't rendering correctly
    Jeff Dillon, Sep 5, 2008
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?bGV0dWNlIGRhbmNl?=

    why does Response.ContentType = "text/plain"; not work correctly?

    =?Utf-8?B?bGV0dWNlIGRhbmNl?=, Oct 26, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    1,146
    =?Utf-8?B?bGV0dWNlIGRhbmNl?=
    Oct 26, 2006
  2. dddan
    Replies:
    2
    Views:
    1,022
    David C
    Dec 14, 2007
  3. Peter
    Replies:
    0
    Views:
    398
    Peter
    Sep 29, 2008
  4. Mauricio Pires

    OnClientClick with confirm doesn't work

    Mauricio Pires, Jan 8, 2009, in forum: ASP .Net Web Controls
    Replies:
    3
    Views:
    1,197
    Jester98x
    Jan 21, 2009
  5. cyrus
    Replies:
    2
    Views:
    207
    Evertjan.
    Sep 2, 2008
Loading...

Share This Page