如何在Asp.Net C#中使用Javascript发布数据 [英] How Can I Post Data Using Javascript In Asp.Net C#

查看:66
本文介绍了如何在Asp.Net C#中使用Javascript发布数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hai和问候,


$ b $我试图在Windows移动设备上进行网络签名,我设法做了一切,但现在我坚持了一些东西,将保存的签名作为图像发回并保存在服务器内的文件夹中..

这里是我的代码:



Hai and greetings,

i am trying to do a web signature to work on windows mobile device , i managed to do everything but now i stuck on something , which is posting back the saved signature as image and save it in a folder inside the server..
here is my code:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SOMainMobileSHDeliveryEndv3_2.aspx.cs" Inherits="AutockWebApplication.SO.SOMobile.SOMainMobileSHDeliveryEndv3_2" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1"  runat="server">
<meta charset="utf-8">
    <title></title>
    <style type="text/css">
        .style1
        {
            width: 91%;
        }
        .style2
        {
        }
        .style3
        {
        }
    </style>
    
</head>
<body style="width: 173px; font-family: Tahoma; font-size: x-small;" 

    bgcolor="#99FF66">
	
    <form id="form1"  runat="server" method="post" action="">
	

	 
    <div>
                <table class="style1">
                    <tr>
                        <td class="style3">
    
        <asp:Label ID="Label1" runat="server" Font-Bold="True" Font-Names="Arial" 

            Text="DELIVERY TO USER"></asp:Label>
    
                        </td>
                        <td>
                <asp:LinkButton ID="LinkButton1" runat="server" 

                    PostBackUrl="~/Mobile/MobileMainPagSH.aspx" BackColor="Yellow">HOME</asp:LinkButton>
    
                        </td>
                    </tr>
        </table>
    
    </div>
    <hr />
    <table class="style1">
        <tr>
<OBJECT ID="alcax" WIDTH=300 HEIGHT=80 CODEBASE ="alcax.ocx" CLASSID="CLSID:078DD2C4-1067-43F9-9107-D6480BE98A93">  </OBJECT>
		<BUTTON > CONFIRM </BUTTON>
                <BUTTON > CLEAR </BUTTON>

            
        </tr>
        <tr>
            <td class="style2">
                <asp:Label ID="Label16" runat="server" Text="Name:"></asp:Label>
            </td>
            <td>
                <asp:TextBox ID="txtReceiver" runat="server" Width="110px" Height="20px"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="style2">
                <asp:Label ID="Label17" runat="server" Text="ContactNo:"></asp:Label>
            </td>
            <td>
                <asp:TextBox ID="txtContactNo" runat="server" Width="110px" Height="20px"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="style2">
                <asp:Label ID="Label8" runat="server" Text="VoucherNo:"></asp:Label>
            </td>
            <td>
                <asp:Label ID="txtSONo" runat="server"></asp:Label>
            </td>
        </tr>
        <tr>
            <td class="style2">
                <asp:Label ID="Label6" runat="server" Text="Ward:"></asp:Label>
            </td>
            <td>
                <asp:Label ID="txtDeptCode" runat="server"></asp:Label>
            </td>
        </tr>
        <tr>
            <td class="style2">
                <asp:Label ID="Label7" runat="server" Text="CostCentre:"></asp:Label>
            </td>
            <td>
                <asp:Label ID="txtCostCentre" runat="server"></asp:Label>
            </td>
        </tr>
        <tr>
            <td class="style2">
                <asp:Label ID="Label9" runat="server" Text="BOM/EIRF:"></asp:Label>
            </td>
            <td>
                <asp:Label ID="txtNote" runat="server"></asp:Label>
            </td>
        </tr>
        <tr>
            <td class="style2">
                <asp:Label ID="Label15" runat="server" Text="TotalItems:"></asp:Label>
            </td>
            <td>
                <asp:Label ID="txtTotalItems" runat="server"></asp:Label>
            </td>
        </tr>
        <tr>
            <td class="style2">
                <asp:Label ID="Label14" runat="server" Text="Status:"></asp:Label>
            </td>
            <td>
                <asp:Label ID="lblStatus" runat="server"></asp:Label>
            </td>
        </tr>
        <tr>
            <td>
                <asp:Label ID="lblUserName" runat="server" Visible="False"></asp:Label>
                <input type="button" id="btnSave" name="btnSave" value="SAVE" 

                    style="width: 75px" onclick=UploadSignature() />
            </td>
        </tr>
    </table>

        <asp:SqlDataSource ID="sqlDSSO" runat="server" 

            ConnectionString="<%$ ConnectionStrings:AED_AUTConnectionString %>" 

            SelectCommand="SELECT TOP (1) DocNo FROM SO order by DocKey Desc" 

            UpdateCommand="alcsp_SODeliveryEndUpdate" 

            UpdateCommandType="StoredProcedure" InsertCommand="alcsp_SOVerifyPick" 

            InsertCommandType="StoredProcedure">
            <InsertParameters>
                <asp:Parameter Name="DocNo" Type="String" />
                <asp:SessionParameter Name="UserID" SessionField="UserID" Type="String" />
                <asp:Parameter Direction="Output" Name="StrOutput" Size="100" Type="String" />
            </InsertParameters>
            <UpdateParameters>
                <asp:Parameter Name="DocNo" Type="String" />
                <asp:Parameter Name="UserID" Type="String" />
                <asp:Parameter Name="StrOutput" Type="String" Direction="Output" Size="100" />
                <asp:Parameter Name="UDF_Department" Type="String" />
                <asp:Parameter Name="UDF_CostCentre" Type="String" />
                <asp:Parameter Name="UDF_ReceiveContact" Type="String" />
                <asp:Parameter Name="UDF_ReceiveSignature" Type="String" />
            </UpdateParameters>
        </asp:SqlDataSource>

    </form>
<script language="javascript">
	//Passing parameters to ActiveX object and starting application
function OpenActiveX1()
{
	try
	{
		
		document.alcax.CaptureSignature(); //Running method from activeX
		alert(document.alcax.GetBitmapByte);
	}
	catch(Err)
	{
		alert(Err.description);
	}
}	

function OpenActiveX2()
{
	try
	{
		
		document.alcax.ClearSignature(); //Running method from activeX
	}
	catch(Err)
	{
		alert(Err.description);
	}
}	

</script>

<script type="text/javascript">
function UploadSignature()
{
try
{
 
 alert("OK NOW");
 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
 var receivername = document.getElementById('<%=txtReceiver.ClientID%>').value;
 var receiverphone = document.getElementById('<%=txtContactNo.ClientID%>').value;
 var image = document.alcax.GetBitmapByte;
 alert(image);
 alert(receivername);
 
  xmlhttp.open("POST","~/SO/SOMOBILE/SOMainMobileSHDeliveryEndv3_2.aspx/UploadImage",true);
              //xmlhttp.setRequestHeader("Content-type","application/x-javascript");
			  xmlhttp.onreadystatechange = function () {
				if (xmlhttp.readyState != 4 || xmlhttp.status != 200) return; 
				     alert("OK MAN!");
				};
			  var datatosend = "imageData : " + image + ",rName : " + receivername + ",rContact : " + receiverphone;
			  alert(datatosend);
              
			  xmlhttp.send(datatosend);

}
catch(err)
{
alert(err.message);
}

}
</script>
</body>
</html>





please feel free to ask me if there’s anything unclear and thanks in advance.



please feel free to ask me if there's anything unclear and thanks in advance.

推荐答案

ConnectionStrings:AED_AUTConnectionString %>\"

< span class=\"code-attribute\"> SelectCommand=\"SELECT TOP (1) DocNo FROM SO order by DocKey Desc\"

UpdateCommand=\"alcsp_SODeliveryEndUpdate\"

UpdateCommandType=\"StoredProcedure\" InsertCommand=\"alcsp_SOVe rifyPick\"

InsertCommandType=\"StoredProcedure\">
<InsertParameters>
<asp:Parameter Name=\"DocNo\" Type=\"String\" />
<asp:SessionParameter Name=\"UserID\" SessionField=\"UserID\" Type=\"String\" />
<asp:Parameter Direction=\"Output\" Name=\"StrOutput\" Size=\"100\" Type=\"String\" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name=\"DocNo\" Type=\"String\" />
<asp:Parameter Name=\"UserID\" Type=\"String\" />
<asp:Parameter Name=\"StrOutput\" Type=\"String\" Direction=\"Output\" Size=\"100\" />
<asp:Parameter Name=\"UDF_Department\" Type=\"String\" />
<asp:Parameter Name=\"UDF_CostCentre\" Type=\"String\" />
<asp:Parameter Name=\"UDF_ReceiveContact\" Type=\"String\" />
<asp:Parameter Name< span class=\"code-keyword\">=\"
UDF_ReceiveSignature\" Type=\"String\" />
</UpdateParameters>
</asp:SqlDataSource>

</form>
<script language=\"javascript\"
>
\t//Passing parameters to ActiveX object and starting application
function OpenActiveX1()
{
\ttry
\t{
\t\t
\t\tdocument.alcax.CaptureSignature(); //Running method from activeX
\t\talert(document.alcax.GetBitmapByte);
\t}
\tcatch(Err)
\t{
\t\talert(Err.description);
\t}
}\t

function OpenActiveX2()
{
\ttry
\t{
\t\t
\t\tdocument.alcax.ClearSignature(); //Running method from activeX
\t}
\tcatch(Err)
\t{
\t\talert(Err.description);
\t}
}\t

</script>

<script type=\"text/javascript\">
function UploadSignature()
{
try
{

alert(\"OK NOW\");
xmlhttp=new ActiveXObject(\"Microsoft.XMLHTTP\");
var receivername = document.getElementById('<%=txtReceiver.ClientID%>').value;
var receiverphone = document.getElementById('<%=txtContactNo.ClientID%>').value;
var image = document.alcax.GetBitmapByte;
alert(image);
alert(receivername);

xmlhttp.open(\"POST\",\"~/SO/SOMOBILE/SOMainMobileSHDeliveryEndv3_2.aspx/UploadImage\",true);
//xmlhttp.setRequestHeader(\"Content-type\",\"application/x-javascript\");
\t\t\t xmlhttp.onreadystatechange = function () {
\t\t\t\tif (xmlhttp.readyState != 4 || xmlhttp.status != 200) return;
\t\t\t\t alert(\"OK MAN!\");
\t\t\t\t};
\t\t\t var datatosend = \"imageData : \" + image + \",rName : \" + receivername + \",rContact : \" + receiverphone;
\t\t\t alert(datatosend);

\t\t\t xmlhttp.send(datatosend);

}
catch(err)
{
alert(err.message);
}

}
</script>
</body>
</html>
ConnectionStrings:AED_AUTConnectionString %>" SelectCommand="SELECT TOP (1) DocNo FROM SO order by DocKey Desc" UpdateCommand="alcsp_SODeliveryEndUpdate" UpdateCommandType="StoredProcedure" InsertCommand="alcsp_SOVerifyPick" InsertCommandType="StoredProcedure"> <InsertParameters> <asp:Parameter Name="DocNo" Type="String" /> <asp:SessionParameter Name="UserID" SessionField="UserID" Type="String" /> <asp:Parameter Direction="Output" Name="StrOutput" Size="100" Type="String" /> </InsertParameters> <UpdateParameters> <asp:Parameter Name="DocNo" Type="String" /> <asp:Parameter Name="UserID" Type="String" /> <asp:Parameter Name="StrOutput" Type="String" Direction="Output" Size="100" /> <asp:Parameter Name="UDF_Department" Type="String" /> <asp:Parameter Name="UDF_CostCentre" Type="String" /> <asp:Parameter Name="UDF_ReceiveContact" Type="String" /> <asp:Parameter Name="UDF_ReceiveSignature" Type="String" /> </UpdateParameters> </asp:SqlDataSource> </form> <script language="javascript"> //Passing parameters to ActiveX object and starting application function OpenActiveX1() { try { document.alcax.CaptureSignature(); //Running method from activeX alert(document.alcax.GetBitmapByte); } catch(Err) { alert(Err.description); } } function OpenActiveX2() { try { document.alcax.ClearSignature(); //Running method from activeX } catch(Err) { alert(Err.description); } } </script> <script type="text/javascript"> function UploadSignature() { try { alert("OK NOW"); xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); var receivername = document.getElementById('<%=txtReceiver.ClientID%>').value; var receiverphone = document.getElementById('<%=txtContactNo.ClientID%>').value; var image = document.alcax.GetBitmapByte; alert(image); alert(receivername); xmlhttp.open("POST","~/SO/SOMOBILE/SOMainMobileSHDeliveryEndv3_2.aspx/UploadImage",true); //xmlhttp.setRequestHeader("Content-type","application/x-javascript"); xmlhttp.onreadystatechange = function () { if (xmlhttp.readyState != 4 || xmlhttp.status != 200) return; alert("OK MAN!"); }; var datatosend = "imageData : " + image + ",rName : " + receivername + ",rContact : " + receiverphone; alert(datatosend); xmlhttp.send(datatosend); } catch(err) { alert(err.message); } } </script> </body> </html>





please feel free to ask me if there’s anything unclear and thanks in advance.



please feel free to ask me if there's anything unclear and thanks in advance.


这篇关于如何在Asp.Net C#中使用Javascript发布数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆