[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

vt

1/23/2003 12:33:00 AM

Hello,

I am popluating a dropdownlist on a footer of a templated column based on a
condition.
After loading all data into the control and databinding it, i want to issue
a messagebox to the user using javascript.

But the following code (located in grid's ItemCommand) doesn't seem to work:
No message box appears.

Dim dd As DropDownList = e.Item.FindControl("ftrGeocode")
dd.DataSource = ds.Tables("wsGeoCodeTable")
dd.DataTextField = "FormatDisplay"
dd.DataValueField = "GeoCode"
dd.Attributes.Add("onDataBinding", "javascript:alert('Please
select a GeoCode');")
dd.DataBind()

Any help is appreciated.

Regards
Trin



5 Answers

sm

1/23/2003 2:05:00 AM

0

First of all there's no client side property called "onDataBinding" so there
will be no event raised as such.
Your best option is to use RegisterScriptBlock to plug in the JavaScript
code in your HTML.

For example:(in C#)

string strJScript = "<SCRIPT LANGUAGE=javascript>";
strJScript += "<!-- \n alert(YourMessage); \n//--></SCRIPT>";
RegisterScriptBlock ("XYZ", str);

HTH,
Suresh.

"vt" <evtv@hotmail.com> wrote in message
news:OhxiV6mwCHA.1296@TK2MSFTNGP11...
> Hello,
>
> I am popluating a dropdownlist on a footer of a templated column based on
a
> condition.
> After loading all data into the control and databinding it, i want to
issue
> a messagebox to the user using javascript.
>
> But the following code (located in grid's ItemCommand) doesn't seem to
work:
> No message box appears.
>
> Dim dd As DropDownList = e.Item.FindControl("ftrGeocode")
> dd.DataSource = ds.Tables("wsGeoCodeTable")
> dd.DataTextField = "FormatDisplay"
> dd.DataValueField = "GeoCode"
> dd.Attributes.Add("onDataBinding",
"javascript:alert('Please
> select a GeoCode');")
> dd.DataBind()
>
> Any help is appreciated.
>
> Regards
> Trin
>
>
>


vt

1/23/2003 5:00:00 PM

0

Suresh,

Thanks. That helps us to add a script dynamically to HTML. But still, how do
we call the script after issuing the databinding (dd.DataBind()) ? Maybe i
am missing something from what you wrote.

Thanks for your help.

"Suresh" <sm20030@hotmail.com> wrote in message
news:er2yqtnwCHA.1640@TK2MSFTNGP09...
> First of all there's no client side property called "onDataBinding" so
there
> will be no event raised as such.
> Your best option is to use RegisterScriptBlock to plug in the JavaScript
> code in your HTML.
>
> For example:(in C#)
>
> string strJScript = "<SCRIPT LANGUAGE=javascript>";
> strJScript += "<!-- \n alert(YourMessage); \n//--></SCRIPT>";
> RegisterScriptBlock ("XYZ", str);
>
> HTH,
> Suresh.
>
> "vt" <evtv@hotmail.com> wrote in message
> news:OhxiV6mwCHA.1296@TK2MSFTNGP11...
> > Hello,
> >
> > I am popluating a dropdownlist on a footer of a templated column based
on
> a
> > condition.
> > After loading all data into the control and databinding it, i want to
> issue
> > a messagebox to the user using javascript.
> >
> > But the following code (located in grid's ItemCommand) doesn't seem to
> work:
> > No message box appears.
> >
> > Dim dd As DropDownList =
e.Item.FindControl("ftrGeocode")
> > dd.DataSource = ds.Tables("wsGeoCodeTable")
> > dd.DataTextField = "FormatDisplay"
> > dd.DataValueField = "GeoCode"
> > dd.Attributes.Add("onDataBinding",
> "javascript:alert('Please
> > select a GeoCode');")
> > dd.DataBind()
> >
> > Any help is appreciated.
> >
> > Regards
> > Trin
> >
> >
> >
>
>


sm

1/23/2003 10:20:00 PM

0

vt,
Unfortunately you cannot tie a server side event to execute something on the
client side. However, you can emulate it. That's why I recommended to add
the script via RegisterScriptBlock or RegisterStartupScript. This will
execute the script as your file is being loaded on to the client's browser.
Is it possible for you tie the alert message to some client side event of
the DropDownList?

Suresh.

"vt" <evtv@hotmail.com> wrote in message
news:et$VCivwCHA.1640@TK2MSFTNGP09...
> Suresh,
>
> Thanks. That helps us to add a script dynamically to HTML. But still, how
do
> we call the script after issuing the databinding (dd.DataBind()) ? Maybe i
> am missing something from what you wrote.
>
> Thanks for your help.
>
> "Suresh" <sm20030@hotmail.com> wrote in message
> news:er2yqtnwCHA.1640@TK2MSFTNGP09...
> > First of all there's no client side property called "onDataBinding" so
> there
> > will be no event raised as such.
> > Your best option is to use RegisterScriptBlock to plug in the JavaScript
> > code in your HTML.
> >
> > For example:(in C#)
> >
> > string strJScript = "<SCRIPT LANGUAGE=javascript>";
> > strJScript += "<!-- \n alert(YourMessage); \n//--></SCRIPT>";
> > RegisterScriptBlock ("XYZ", str);
> >
> > HTH,
> > Suresh.
> >
> > "vt" <evtv@hotmail.com> wrote in message
> > news:OhxiV6mwCHA.1296@TK2MSFTNGP11...
> > > Hello,
> > >
> > > I am popluating a dropdownlist on a footer of a templated column
based
> on
> > a
> > > condition.
> > > After loading all data into the control and databinding it, i want to
> > issue
> > > a messagebox to the user using javascript.
> > >
> > > But the following code (located in grid's ItemCommand) doesn't seem to
> > work:
> > > No message box appears.
> > >
> > > Dim dd As DropDownList =
> e.Item.FindControl("ftrGeocode")
> > > dd.DataSource = ds.Tables("wsGeoCodeTable")
> > > dd.DataTextField = "FormatDisplay"
> > > dd.DataValueField = "GeoCode"
> > > dd.Attributes.Add("onDataBinding",
> > "javascript:alert('Please
> > > select a GeoCode');")
> > > dd.DataBind()
> > >
> > > Any help is appreciated.
> > >
> > > Regards
> > > Trin
> > >
> > >
> > >
> >
> >
>
>


Zeeshan

1/23/2003 10:57:00 PM

0

How would you access a serverside control like dropdown
control from client side javascript

Zeeshan

>-----Original Message-----
>vt,
>Unfortunately you cannot tie a server side event to
execute something on the
>client side. However, you can emulate it. That's why I
recommended to add
>the script via RegisterScriptBlock or
RegisterStartupScript. This will
>execute the script as your file is being loaded on to the
client's browser.
>Is it possible for you tie the alert message to some
client side event of
>the DropDownList?
>
>Suresh.
>
>"vt" <evtv@hotmail.com> wrote in message
>news:et$VCivwCHA.1640@TK2MSFTNGP09...
>> Suresh,
>>
>> Thanks. That helps us to add a script dynamically to
HTML. But still, how
>do
>> we call the script after issuing the databinding
(dd.DataBind()) ? Maybe i
>> am missing something from what you wrote.
>>
>> Thanks for your help.
>>
>> "Suresh" <sm20030@hotmail.com> wrote in message
>> news:er2yqtnwCHA.1640@TK2MSFTNGP09...
>> > First of all there's no client side property
called "onDataBinding" so
>> there
>> > will be no event raised as such.
>> > Your best option is to use RegisterScriptBlock to
plug in the JavaScript
>> > code in your HTML.
>> >
>> > For example:(in C#)
>> >
>> > string strJScript = "<SCRIPT LANGUAGE=javascript>";
>> > strJScript += "<!-- \n alert(YourMessage); \n//--
></SCRIPT>";
>> > RegisterScriptBlock ("XYZ", str);
>> >
>> > HTH,
>> > Suresh.
>> >
>> > "vt" <evtv@hotmail.com> wrote in message
>> > news:OhxiV6mwCHA.1296@TK2MSFTNGP11...
>> > > Hello,
>> > >
>> > > I am popluating a dropdownlist on a footer of a
templated column
>based
>> on
>> > a
>> > > condition.
>> > > After loading all data into the control and
databinding it, i want to
>> > issue
>> > > a messagebox to the user using javascript.
>> > >
>> > > But the following code (located in grid's
ItemCommand) doesn't seem to
>> > work:
>> > > No message box appears.
>> > >
>> > > Dim dd As DropDownList =
>> e.Item.FindControl("ftrGeocode")
>> > > dd.DataSource = ds.Tables
("wsGeoCodeTable")
>> > > dd.DataTextField = "FormatDisplay"
>> > > dd.DataValueField = "GeoCode"
>> > > dd.Attributes.Add("onDataBinding",
>> > "javascript:alert('Please
>> > > select a GeoCode');")
>> > > dd.DataBind()
>> > >
>> > > Any help is appreciated.
>> > >
>> > > Regards
>> > > Trin
>> > >
>> > >
>> > >
>> >
>> >
>>
>>
>
>
>.
>

vt

1/23/2003 11:40:00 PM

0

Yes. We changed the design a little to handle the above issue.

We replaced the DropDownList with a RadioButtonList and added a
requiredfieldvalidator to the RadioButtonList.

This way, instead of displaying a message box requesting user to enter the
data before they enter, this way we display the messagebox if they do not
enter.

Not exactly elegant, but will keep us moving to the next stage.

Thanks for your help.

"Suresh" <sm20030@hotmail.com> wrote in message
news:OEhhIVywCHA.1632@TK2MSFTNGP12...
> vt,
> Unfortunately you cannot tie a server side event to execute something on
the
> client side. However, you can emulate it. That's why I recommended to
add
> the script via RegisterScriptBlock or RegisterStartupScript. This will
> execute the script as your file is being loaded on to the client's
browser.
> Is it possible for you tie the alert message to some client side event of
> the DropDownList?
>
> Suresh.
>
> "vt" <evtv@hotmail.com> wrote in message
> news:et$VCivwCHA.1640@TK2MSFTNGP09...
> > Suresh,
> >
> > Thanks. That helps us to add a script dynamically to HTML. But still,
how
> do
> > we call the script after issuing the databinding (dd.DataBind()) ? Maybe
i
> > am missing something from what you wrote.
> >
> > Thanks for your help.
> >
> > "Suresh" <sm20030@hotmail.com> wrote in message
> > news:er2yqtnwCHA.1640@TK2MSFTNGP09...
> > > First of all there's no client side property called "onDataBinding" so
> > there
> > > will be no event raised as such.
> > > Your best option is to use RegisterScriptBlock to plug in the
JavaScript
> > > code in your HTML.
> > >
> > > For example:(in C#)
> > >
> > > string strJScript = "<SCRIPT LANGUAGE=javascript>";
> > > strJScript += "<!-- \n alert(YourMessage); \n//--></SCRIPT>";
> > > RegisterScriptBlock ("XYZ", str);
> > >
> > > HTH,
> > > Suresh.
> > >
> > > "vt" <evtv@hotmail.com> wrote in message
> > > news:OhxiV6mwCHA.1296@TK2MSFTNGP11...
> > > > Hello,
> > > >
> > > > I am popluating a dropdownlist on a footer of a templated column
> based
> > on
> > > a
> > > > condition.
> > > > After loading all data into the control and databinding it, i want
to
> > > issue
> > > > a messagebox to the user using javascript.
> > > >
> > > > But the following code (located in grid's ItemCommand) doesn't seem
to
> > > work:
> > > > No message box appears.
> > > >
> > > > Dim dd As DropDownList =
> > e.Item.FindControl("ftrGeocode")
> > > > dd.DataSource = ds.Tables("wsGeoCodeTable")
> > > > dd.DataTextField = "FormatDisplay"
> > > > dd.DataValueField = "GeoCode"
> > > > dd.Attributes.Add("onDataBinding",
> > > "javascript:alert('Please
> > > > select a GeoCode');")
> > > > dd.DataBind()
> > > >
> > > > Any help is appreciated.
> > > >
> > > > Regards
> > > > Trin
> > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>