Ask a Question related to ASP.NET General, Design and Development.
-
KathyB #1
why window.open script not firing? just postback...continuation of previous post
Hi,
In the pageload of my aspx file I have the following (in both not in
postback and is postback)...
btnList.Attributes.Add("onclick", "window.open('Scanned.aspx', 'Serial
Numbers', 'width=200, height=300');")
When sent to the browser (ie 6) it appears as:
<input type="submit" name="btnList" value="Show List" id="btnList"
onClick="window.open('Scanned.aspx', 'Serial Numbers', 'width=200,
height=300');" style=the usual asp stuff...
Please tell me why this is still posting back to the originating page
instead of opening the new window...what am I missing? I would prefer
to use the Attribute.Add collection since it is easier than having to
go change each html input element.
Thanks,
Kathy
KathyB Guest
-
Control not maintaing viewState and PostBack not firing event.
I created a nWeb Custom Control that inherits from WebControls.Panel and add a CheckBoxList to this control. I can't seem to get this control to... -
Postback for DataGrid Columns Added in Code Behind not firing.
I am trying to build a web custom control that displays a datagrid, so first off I have no designer where I can drag and drop a datagrid and then... -
Server Control - Datagrid paging event - not firing for previous pages
Hello All I am having a pretty wired problem...I am writing a web part (SPS 2003) that uses a Datagrid. In the web part, I create the datagird... -
Sort not firing PostBack event using Dynamic Columns
I am having a problem with the DataGrid control and sorting, and have found it's realted to if you use dynamic columns or not. If I set the columns... -
javascript open window and a PHP script...
I have a link on a page... <a href="./admin/?listType=event_list&action=item_add" target=_blank> Add or Update Your Event </a> This open the... -
Vidar Petursson #2
Re: why window.open script not firing? just postback...continuation of previous post
Hi
Because the button is a submit btn so it submits onclick unless you cancel
it
Fix:
btnList.Attributes.Add("onclick", "window.open('Scanned.aspx', 'Serial
Numbers', 'width=200, height=300'); return false");
--
Best Regards
Vidar Petursson
==============================
Microsoft Internet Client & Controls MVP
==============================
"KathyB" <KathyBurke40@attbi.com> wrote in message
news:75e8d381.0307170601.5e8c236e@posting.google.c om...> Hi,
>
> In the pageload of my aspx file I have the following (in both not in
> postback and is postback)...
>
> btnList.Attributes.Add("onclick", "window.open('Scanned.aspx', 'Serial
> Numbers', 'width=200, height=300');")
>
> When sent to the browser (ie 6) it appears as:
>
> <input type="submit" name="btnList" value="Show List" id="btnList"
> onClick="window.open('Scanned.aspx', 'Serial Numbers', 'width=200,
> height=300');" style=the usual asp stuff...
>
> Please tell me why this is still posting back to the originating page
> instead of opening the new window...what am I missing? I would prefer
> to use the Attribute.Add collection since it is easier than having to
> go change each html input element.
>
> Thanks,
>
> Kathy
Vidar Petursson Guest
-
Mario Vargas #3
Re: why window.open script not firing? just postback...continuation of previous post
Kathy,
The button is posting back because the "type" property of the <input />
tag is "submit." Try using an HtmlInputButton control, which is basically
<input type="button" id="myBtn" runat="server" value="My Button" />
and then you can access the attributes property in your Page_Load code.
If you don't want your current button, which I believe is a Button
WebControl (i.e. <asp:Button runat="server" />) then you must append "return
false;" after invoking the window.open() method:
btnList.Attributes.Add("onclick", "window.open('Scanned.aspx', 'Serial
Numbers', 'width=200, height=300'); return false;")
This will prevent the button from submitting the form.
Question: Why do you need to add this code in your code behind instead of
directly in the HTML? This is how you do that:
<input type="button" name="btnList" value="Show List" id="btnList"
onclick="window.open('Scanned.aspx', 'Serial Numbers', 'width=200,
height=300');"
Notice that I didn't use the runat="server" property.
I hope that helps.
Mario
"KathyB" <KathyBurke40@attbi.com> wrote in message
news:75e8d381.0307170601.5e8c236e@posting.google.c om...> Hi,
>
> In the pageload of my aspx file I have the following (in both not in
> postback and is postback)...
>
> btnList.Attributes.Add("onclick", "window.open('Scanned.aspx', 'Serial
> Numbers', 'width=200, height=300');")
>
> When sent to the browser (ie 6) it appears as:
>
> <input type="submit" name="btnList" value="Show List" id="btnList"
> onClick="window.open('Scanned.aspx', 'Serial Numbers', 'width=200,
> height=300');" style=the usual asp stuff...
>
> Please tell me why this is still posting back to the originating page
> instead of opening the new window...what am I missing? I would prefer
> to use the Attribute.Add collection since it is easier than having to
> go change each html input element.
>
> Thanks,
>
> Kathy
Mario Vargas Guest



Reply With Quote

