[Solved] JavaScript Error: ReferenceError: platform is not defined

on Nov 15, 2022 09:40 PM

Set TextBox on ASP.Net GridView row selection using JavaScript from Code Behind

I have tried it but is not generating any voice with Mozilla Firefox and i wanted it in a way that the moment i click the ok button the voice should automatically be played.

Thank you for the big effort.

It is also showing this error if i open it with other browsers like chrome.

ReferenceError: platform is not defined
Download FREE API for Word, Excel and PDF in ASP.Net: Download
on Nov 16, 2022 12:19 AM
on Nov 16, 2022 12:20 AM

Hi makumbi,

Please refer below sample.


<asp:GridView ID="gvCustomer" runat="server" AutoGenerateColumns="False" Width="405px">
        <asp:BoundField DataField="CustomerId" HeaderText="CustomerId" />
        <asp:BoundField DataField="Name" HeaderText="Name" />
        <asp:BoundField DataField="Country" HeaderText="Country" />
                <asp:Button Text="View" runat="server" OnClick="OnViewDetails" />
<input id="text" runat="server" />
<button onclick="talk()">
    Talk It!</button>&nbsp;
<button onclick="listen()">
<select id="Language">
    <option value="en">English</option>
    <option value="fr">French</option>
<script src="webspeech-master/src/webspeech.js" type="text/javascript"></script>
<script type="text/javascript">
    var speaker, listener;
    window.onload = function () {
        ws = webSpeechNoConflict();
        try {
            speaker = new ws.Speaker();
            speaker.onEnd(function () {
                console.log('just finished talking...');
        catch (ex) {
            speaker = null;
            document.getElementById("status").innerHTML = ex;
        try {
            listener = new ws.Listener();
        catch (ex) {
            listener = null;
            document.getElementById("status").innerHTML = ex;
    function talk() {
        if (speaker) {
            speaker.speak(document.getElementById("Language").value, document.getElementById("text").value);

    function listen() {
        if (listener) {
            listener.listen(document.getElementById("Language").value, function (text) {
                document.getElementById("text").value = text;



using System.Data;


Imports System.Data



protected void Page_Load(object sender, EventArgs e)
    if (!this.IsPostBack)
        DataTable dt = new DataTable();
        dt.Columns.AddRange(new DataColumn[] { 
                            new DataColumn("CustomerId"),
                            new DataColumn("Name"),
                            new DataColumn("Country")});
        dt.Rows.Add(1, "John Hammond", "United States");
        dt.Rows.Add(2, "Mudassar Khan", "India");
        dt.Rows.Add(3, "Suzanne Mathews", "France");
        dt.Rows.Add(4, "Robert Schidner", "Russia");
        gvCustomer.DataSource = dt;

protected void OnViewDetails(object sender, EventArgs e)
    GridViewRow row = (sender as Button).NamingContainer as GridViewRow;
    string customerId = row.Cells[0].Text;
    string name = row.Cells[1].Text;
    string country = row.Cells[2].Text;
    string message = "\\nCustomerId: " + customerId  + "\\nName: " + name  + "\\nCountry: " + country;               
    text.Value = name;
    ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('" + message + "');", true);


Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
    If Not Me.IsPostBack Then
        Dim dt As New DataTable
        dt.Columns.AddRange(New DataColumn() {
                            New DataColumn("CustomerId"),
                            New DataColumn("Name"),
                            New DataColumn("country")})
        dt.Rows.Add(1, "John Hammond", "United States")
        dt.Rows.Add(2, "Mudassar Khan", "India")
        dt.Rows.Add(3, "Suzanne Mathews", "France")
        dt.Rows.Add(4, "Robert Schidner", "Russia")
        gvCustomer.DataSource = dt
    End If
End Sub

Protected Sub OnViewDetails(ByVal sender As Object, ByVal e As EventArgs)
    Dim row As GridViewRow = TryCast((TryCast(sender, Button)).NamingContainer, GridViewRow)
    Dim customerId As String = row.Cells(0).Text
    Dim name As String = row.Cells(1).Text
    Dim country As String = row.Cells(2).Text
    Dim message As String = "\nCustomerId: " & customerId & "\nName: " & name & "\nCountry: " & country
    text.Value = name
    ClientScript.RegisterStartupScript(Me.GetType(), "alert", "alert('" & message & "');", True)
End Sub