Client Side Office Automation referencing ASP.net server controls

M

Mike Shapleski

I am trying to write an aspx page that opens a populates a word
document.
As I understand it this Office automation should be done on the client
side.

However i can't get my Vbscript procedures referencing the ASP.NET
dropdown list values

There must be a simple way to do it, I have been 'looking' for an
answer for a few days now and I'm only getting closer to my deadline.

The page as I would like it work is ..
1.Popluate a ASP.NET drop down box with values for the users to select
from
2.User selects a value and clicks a button which calls a Client side
procedure
3.The client side procedure (VBscript) reads the value form the
ASP.NET dropdown box, goes and gets a Recordset and populates the word
document.

I have tried so many variations on the 'str =
document.Forms("ddlData").value'
syntax I losing the plot...!

M.Shapleski

NOTE:
I did find one way to achive what I want but it seams messy..
This changed the an atribute of a button that fired off the client
code, it effectivly pre-populated the procedure call with the varible
I want the read.

Sub ddlDataChangeCode(objSender As Object, objArgs As EventArgs)
btnRunClientCode.Attributes.add("onclick","VBScript:ButtonClick("&
ShipMethod.SelectedItem.value & ")")
end sub

Code Listing....
-------------------------------------------------------------------------------
<%@ Page Language="vb" Debug="true" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.SqlClient" %>
<script runat="server">

Sub Page_Load(Source As Object, E As EventArgs)
If Not Page.IsPostBack Then
Dim myConnection As SqlConnection
Dim myCommand As SqlCommand
Dim myReader As SqlDataReader
Dim SQL As String
Dim ConnStr As String
SQL = "SELECT * FROM tblData"
ConnStr = "Data Source=xxxxx;" & _
"Initial Catalog=xxxx;" & _
"Integrated Security=SSPI"
myConnection = New SqlConnection(ConnStr)
myConnection.Open()
myCommand = New SqlCommand(SQL, myConnection)
myReader = myCommand.ExecuteReader()
ShipMethod.DataSource = myReader
ShipMethod.DataBind()
end if


End Sub


</script>
<html>
<head>
<form runat = server ID="DOIT">
<asp:DropDownList id="ddlData" runat="server" DataTextField="Desc"
DataValueField="DataID">
</asp:DropDownList>
</form>

</head>
<body>

<p>Please select your delivery method:
<script language="VBScript">
sub ButtonClick()
dim str
str = document.Forms("ddlData").value
msgbox "str = " & str

end sub
</script>
</p>
<form name="form1" method="post" action="">
<input type="button" name="Button" value="Button"
onClick="buttonclick()">
</form>
<p>&nbsp; </p>
</body>
</html>
 
M

Mike Shapleski

Thanks for the prompt reply, Yes the article had the answer. Based on
the client side section at the bottom I used 'igroupID =
document.all.item("ddlGroup").value' in my script and worked a treat
(looks like I need to understand the document object better :).The rest
of the article helped plug a few holes in my understanding of ASP.NET.
It's well set out article.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top