effecting postback without auto postback controls

Discussion in 'ASP .Net' started by Psych971, Dec 17, 2004.

  1. Psych971

    Psych971 Guest

    Hi, I'm wondering how I can generate a postback using javascript on a page
    that does not have any controls with the auto-postback property set to true.
    I know I can just use the submit() function but this triggers page
    validation which I do not want. What I'm trying to do is dynamically write
    in a hyperlink that when clicked will remove an item from the form, so I
    don't want any validation to occur because the form isn't being submitted at
    that point. And because there are no auto-postback controls the server does
    not write in the javascript which would be used to effect the postback so I
    can't just insert "onclick("__doPostBack('','');")". Is there an easy way to
    do this without manually inserting a bunch of javascript code? More
    concisely... How do I manually effect a postback without triggering page
    validation?

    Thanks!
    Richard
     
    Psych971, Dec 17, 2004
    #1
    1. Advertising

  2. Psych971

    Karl Seguin Guest

    Although there is a way to do postback without manually inserting all the
    javascript, why not just use a linkbutton (hence all javascript is written
    for you) and simply set it's CausesValidation to false?

    Karl

    --
    MY ASP.Net tutorials
    http://www.openmymind.net/


    "Psych971" <> wrote in message
    news:_fEwd.1950$...
    > Hi, I'm wondering how I can generate a postback using javascript on a page
    > that does not have any controls with the auto-postback property set to

    true.
    > I know I can just use the submit() function but this triggers page
    > validation which I do not want. What I'm trying to do is dynamically write
    > in a hyperlink that when clicked will remove an item from the form, so I
    > don't want any validation to occur because the form isn't being submitted

    at
    > that point. And because there are no auto-postback controls the server

    does
    > not write in the javascript which would be used to effect the postback so

    I
    > can't just insert "onclick("__doPostBack('','');")". Is there an easy way

    to
    > do this without manually inserting a bunch of javascript code? More
    > concisely... How do I manually effect a postback without triggering page
    > validation?
    >
    > Thanks!
    > Richard
    >
    >
     
    Karl Seguin, Dec 17, 2004
    #2
    1. Advertising

  3. Psych971

    Psych971 Guest

    Because I'm writing dynamically into the response file i don't think you can
    insert asp controls, can you?

    thanks,
    richard

    "Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
    wrote in message news:...
    > Although there is a way to do postback without manually inserting all the
    > javascript, why not just use a linkbutton (hence all javascript is written
    > for you) and simply set it's CausesValidation to false?
    >
    > Karl
    >
    > --
    > MY ASP.Net tutorials
    > http://www.openmymind.net/
    >
    >
    > "Psych971" <> wrote in message
    > news:_fEwd.1950$...
    >> Hi, I'm wondering how I can generate a postback using javascript on a
    >> page
    >> that does not have any controls with the auto-postback property set to

    > true.
    >> I know I can just use the submit() function but this triggers page
    >> validation which I do not want. What I'm trying to do is dynamically
    >> write
    >> in a hyperlink that when clicked will remove an item from the form, so I
    >> don't want any validation to occur because the form isn't being submitted

    > at
    >> that point. And because there are no auto-postback controls the server

    > does
    >> not write in the javascript which would be used to effect the postback so

    > I
    >> can't just insert "onclick("__doPostBack('','');")". Is there an easy way

    > to
    >> do this without manually inserting a bunch of javascript code? More
    >> concisely... How do I manually effect a postback without triggering page
    >> validation?
    >>
    >> Thanks!
    >> Richard
    >>
    >>

    >
    >
     
    Psych971, Dec 17, 2004
    #3
  4. Psych971

    Karl Seguin Guest

    Are you dynamically creating it via

    LinkButton lb = new LinkButton()
    someControl.Controls.Add(lb);

    or are you actually writing it to the html/aspx file via a streamwriter or
    something? If it's the first one, don't see why you can't add
    causesValidatation = false...if its the second case (god why?) then you are
    in trouble...

    Karl

    --
    MY ASP.Net tutorials
    http://www.openmymind.net/


    "Psych971" <> wrote in message
    news:0QEwd.1850$...
    > Because I'm writing dynamically into the response file i don't think you

    can
    > insert asp controls, can you?
    >
    > thanks,
    > richard
    >
    > "Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
    > wrote in message news:...
    > > Although there is a way to do postback without manually inserting all

    the
    > > javascript, why not just use a linkbutton (hence all javascript is

    written
    > > for you) and simply set it's CausesValidation to false?
    > >
    > > Karl
    > >
    > > --
    > > MY ASP.Net tutorials
    > > http://www.openmymind.net/
    > >
    > >
    > > "Psych971" <> wrote in message
    > > news:_fEwd.1950$...
    > >> Hi, I'm wondering how I can generate a postback using javascript on a
    > >> page
    > >> that does not have any controls with the auto-postback property set to

    > > true.
    > >> I know I can just use the submit() function but this triggers page
    > >> validation which I do not want. What I'm trying to do is dynamically
    > >> write
    > >> in a hyperlink that when clicked will remove an item from the form, so

    I
    > >> don't want any validation to occur because the form isn't being

    submitted
    > > at
    > >> that point. And because there are no auto-postback controls the server

    > > does
    > >> not write in the javascript which would be used to effect the postback

    so
    > > I
    > >> can't just insert "onclick("__doPostBack('','');")". Is there an easy

    way
    > > to
    > >> do this without manually inserting a bunch of javascript code? More
    > >> concisely... How do I manually effect a postback without triggering

    page
    > >> validation?
    > >>
    > >> Thanks!
    > >> Richard
    > >>
    > >>

    > >
    > >

    >
    >
     
    Karl Seguin, Dec 17, 2004
    #4
  5. Psych971

    Psych971 Guest

    You've shown me the light! I was doing it the second way but it my first
    ..net page so what'd you expect? :) Will switch to LinkButton.. thanks so
    much! ASP.NET rules!!

    peace out,
    richard

    "Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
    wrote in message news:...
    > Are you dynamically creating it via
    >
    > LinkButton lb = new LinkButton()
    > someControl.Controls.Add(lb);
    >
    > or are you actually writing it to the html/aspx file via a streamwriter or
    > something? If it's the first one, don't see why you can't add
    > causesValidatation = false...if its the second case (god why?) then you
    > are
    > in trouble...
    >
    > Karl
    >
    > --
    > MY ASP.Net tutorials
    > http://www.openmymind.net/
    >
    >
    > "Psych971" <> wrote in message
    > news:0QEwd.1850$...
    >> Because I'm writing dynamically into the response file i don't think you

    > can
    >> insert asp controls, can you?
    >>
    >> thanks,
    >> richard
    >>
    >> "Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
    >> wrote in message news:...
    >> > Although there is a way to do postback without manually inserting all

    > the
    >> > javascript, why not just use a linkbutton (hence all javascript is

    > written
    >> > for you) and simply set it's CausesValidation to false?
    >> >
    >> > Karl
    >> >
    >> > --
    >> > MY ASP.Net tutorials
    >> > http://www.openmymind.net/
    >> >
    >> >
    >> > "Psych971" <> wrote in message
    >> > news:_fEwd.1950$...
    >> >> Hi, I'm wondering how I can generate a postback using javascript on a
    >> >> page
    >> >> that does not have any controls with the auto-postback property set to
    >> > true.
    >> >> I know I can just use the submit() function but this triggers page
    >> >> validation which I do not want. What I'm trying to do is dynamically
    >> >> write
    >> >> in a hyperlink that when clicked will remove an item from the form, so

    > I
    >> >> don't want any validation to occur because the form isn't being

    > submitted
    >> > at
    >> >> that point. And because there are no auto-postback controls the server
    >> > does
    >> >> not write in the javascript which would be used to effect the postback

    > so
    >> > I
    >> >> can't just insert "onclick("__doPostBack('','');")". Is there an easy

    > way
    >> > to
    >> >> do this without manually inserting a bunch of javascript code? More
    >> >> concisely... How do I manually effect a postback without triggering

    > page
    >> >> validation?
    >> >>
    >> >> Thanks!
    >> >> Richard
    >> >>
    >> >>
    >> >
    >> >

    >>
    >>

    >
    >
     
    Psych971, Dec 17, 2004
    #5
  6. Psych971

    bruce barker Guest

    I just wrote a control to do this. basically it registers a javascript
    function doPostBack(arg), that client code can call. I added a standard
    server event handling, so the client can call a know routine.

    string script = "<script language=\"JavaScript\">function
    doPostBack(a,v,fn){__doPostBack('"
    + this.UniqueID + "',a,v,fn);}</script>\n";
    if(!this.Page.IsClientScriptBlockRegistered("doPostBack"))
    this.Page.RegisterClientScriptBlock("doPostBack",script);
    Page.GetPostBackEventReference(this);

    the trick is, Page.GetPostBackEventReference(this), this call is what
    triggers .net generating the autopostback code.

    -- bruce (sqlwork.com)


    "Psych971" <> wrote in message
    news:_fEwd.1950$...
    | Hi, I'm wondering how I can generate a postback using javascript on a page
    | that does not have any controls with the auto-postback property set to
    true.
    | I know I can just use the submit() function but this triggers page
    | validation which I do not want. What I'm trying to do is dynamically write
    | in a hyperlink that when clicked will remove an item from the form, so I
    | don't want any validation to occur because the form isn't being submitted
    at
    | that point. And because there are no auto-postback controls the server
    does
    | not write in the javascript which would be used to effect the postback so
    I
    | can't just insert "onclick("__doPostBack('','');")". Is there an easy way
    to
    | do this without manually inserting a bunch of javascript code? More
    | concisely... How do I manually effect a postback without triggering page
    | validation?
    |
    | Thanks!
    | Richard
    |
    |
     
    bruce barker, Dec 17, 2004
    #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. Chumley the Walrus

    Style tag not effecting links in paging from datagrid

    Chumley the Walrus, Aug 4, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    367
    Chumley the Walrus
    Aug 4, 2004
  2. =?Utf-8?B?TWFya0F1cml0?=

    GRIDVIEW: Effecting buttonfields on single gridview rows

    =?Utf-8?B?TWFya0F1cml0?=, May 23, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    495
    =?Utf-8?B?TWFya0F1cml0?=
    May 23, 2006
  3. Replies:
    4
    Views:
    405
    Jack Klein
    Jul 2, 2006
  4. linkswanted
    Replies:
    1
    Views:
    970
  5. Mothra
    Replies:
    10
    Views:
    487
    Anno Siegel
    Mar 11, 2005
Loading...

Share This Page