About eWebEditor.Image save to database


前台:
<% @ Page Language="VB" EnableEventValidation="false" ValidateRequest="false" AutoEventWireup="false" CodeFile="Default3.aspx.vb" Inherits="Default3"  %>

<! 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  runat ="server" >
    
< title > About eWebEditor.Image save to database DEMO </ title >
  
< script  language ="JavaScript"  type ="text/javascript" >
    
// 当上传图片时,往下拉框中填入图片路径
    function doChange(objText, objDrop)
    
{
        
if (!objDrop) return;
        
var str = objText.value;
        
var arr = str.split("|");
        
var nIndex = objDrop.selectedIndex;
        objDrop.length
=1;
        
for (var i=0; i<arr.length; i++){
            objDrop.options[objDrop.length] 
= new Option(arr[i], arr[i]);
        }

        objDrop.selectedIndex 
= nIndex;
        
        FillData()  
//同时触发填充事件
    }

    
    
function FillData() //事件,将数据传送到后台
        {
            
var img = "";
              
for(i=1;i<document.getElementById("d_picture").options.length;i++)
                
{                    
                    img
= img + document.getElementById("d_picture").options(i).text + ",";   
           
                }

              img 
= img + "|" + document.all.Text1.value;
            
<% =ClientScript.GetCallbackEventReference( Me,"img","Test",Nothing) %>;
        }

        
    
function Test(){}
    
    
function SelectedImg(myImg)
        
{   
            document.all.Text1.value 
= myImg; 
            FillData();
        }

   
</ script >
</ head >
< body >
    
< form  id ="form1"  runat ="server" >
    
< div >
        
< select  id ="d_picture"  onchange ="SelectedImg(this.options[this.options.selectedIndex].text)"   >
            
< option  selected ="selected" > 请选择图片 </ option >
        
</ select >
        
&nbsp;
        
< input  id ="Text1"  type ="text"   />< br  />
        
&nbsp; < asp:TextBox  ID ="txtContent"  runat ="server"  Width ="1" ></ asp:TextBox >
        
< input  type ="hidden"  Onchange ="doChange(this,d_picture)"  name ="d_savefilename" >< br  />
        
< iframe  id ="eWebEditor1"  src ="file/ewebeditor.asp?id=txtContent&amp;style=s_red1&amp;originalfilename=d_originalfilename&amp;savefilename=d_savefilename&amp;savepathfilename=d_savepathfilename"
                frameborder
="0"  width ="550"  scrolling ="no"  height ="350" ></ iframe >
        
< br  />
        
< br  />  
        
< asp:Button  ID ="Button1"  runat ="server"  Text ="  Add  "    />
         
< br  />< asp:Label  ID ="Label1"  runat ="server"  Text ="Label"  Width ="79px" ></ asp:Label ></ div >
    
</ form >
</ body >
</ html >

后台:

Partial 
Class Default3
    
Inherits System.Web.UI.Page
    
Implements ICallbackEventHandler

    
Public Shared imgList As String = ""

    
Public Function GetCallbackResult() As String Implements System.Web.UI.ICallbackEventHandler.GetCallbackResult
        
Return imgList
    
End Function


    
Public Sub RaiseCallbackEvent(ByVal eventArgument As StringImplements System.Web.UI.ICallbackEventHandler.RaiseCallbackEvent
        imgList 
= eventArgument
    
End Sub


    
Protected Sub Button1_Click(ByVal sender As ObjectByVal e As System.EventArgs) Handles Button1.Click
        
Me.Label1.Text = "图片列表是:  " & IIf(imgList.TrimEnd(","= """no", imgList.TrimEnd(","))
    
End Sub

End Class

你可能感兴趣的:(database)