2013-11-04 2 views
0

리피터 컨트롤의 deatail 섹션 안에 링크 버튼이 있습니다. 편집에서 asp.net 텍스트 박스는 백 컬러 변경으로 활성화됩니다. 값을 저장하면 값이 데이터베이스에 저장됩니다. 다시 게시물을 피하기 위해 자바 스크립트 function.How에 링크 사이드 버튼을 클릭하면 java 스크립트에서 동일한 작업을 수행하는 함수를 작성할 수 있습니다. 링크 업데이트 버튼 -> 자바 스크립트 함수에서 동일한 작업을 수행 할 수 있습니까?리피터 세부 구역 내부의 링크 버튼

미리 감사드립니다.

  <asp:LinkButton ID="lnkEdit" runat="server" CommandName="edit" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "LicenseID") %>' CausesValidation="False" onClientClick="JSFunction();return false">Edit</asp:LinkButton> 

     <asp:LinkButton Visible="true" ID="LinkButton5" runat="server" CommandName="update" CommandArgument='<%# DataBinder.Eval (Container.DataItem, "LicenseID") %>' CausesValidation="False" onClientClick="MyJSFunction();return false" >Update</asp:LinkButton> 

If e.CommandName = "edit" Then 

     DirectCast(e.Item.FindControl("TextBox2"), TextBox).Enabled = True 
     DirectCast(e.Item.FindControl("Textbox2"), TextBox).BorderStyle = BorderStyle.NotSet 
     DirectCast(e.Item.FindControl("Textbox2"), TextBox).BackColor = Drawing.Color.White 
    end if 

If e.CommandName = "update" Then 

      Dim bookName As String = DirectCast(e.Item.FindControl("Textbox2"), TextBox).Text 

      Dim author As String = DirectCast(e.Item.FindControl("TextBox3"), TextBox).Text 

      Dim pub As String = DirectCast(e.Item.FindControl("TextBox4"), TextBox).Text 

      Dim price As String = DirectCast(e.Item.FindControl("TextBox5"), TextBox).Text 

      Dim adp As New SqlDataAdapter("Update abc set License= @License, [email protected],[email protected],[email protected] where LicenseID = @LicenseID", con) 

      adp.SelectCommand.Parameters.AddWithValue("@LicenseName", bookName) 

      adp.SelectCommand.Parameters.AddWithValue("@StartDate", author) 

      adp.SelectCommand.Parameters.AddWithValue("@Renewal", pub) 

      adp.SelectCommand.Parameters.AddWithValue("@VendorPONo", price) 

      adp.SelectCommand.Parameters.AddWithValue("@LicenseID", e.CommandArgument) 

      Dim ds As New DataSet() 

      adp.Fill(ds) 

      BindRepeater() 

     End If 

내가 아래 텍스트 상자를 가능하게하기위한 시도 EDIT

는 'TextBox4'는 선언되지 않았습니다. 보호 수준 오류가 표시되어 액세스 할 수 없습니다.

 <script type="text/javascript"> 
     function MyJSFunction() { 

      var textBox = document.getElementById("<%=TextBox4.ClientID %>"); 
      textBox.enabled = true; 
      textBox.focus(); 
     } 
</script> 

답변

1

정확하게 이해하면 찾고있는 것은 OnClientClick입니까? 클라이언트 쪽 Linkbutton 컨트롤의 OnClientClick 이벤트에서 자바 스크립트 함수를 호출 할 수 있습니다.

<asp:LinkButton Visible="false" ID="lnkUpdate" runat="server" 
CommandName="update" 
CommandArgument='<%# DataBinder.Eval(Container.DataItem, "LicenseID") %>' 
CausesValidation="False" OnClientScript='MyJSFunction();return false'>Update</asp:LinkButton> 

이것 좀 봐 : http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.linkbutton.onclientclick.aspx

은 내가 'false를 반환'으로 aswer을 편집했다. adcd shsu 덕분에

+0

미안 ... 내가 즉, 자바 스크립트 함수에서 같은 (업데이트) 할 수있는 당신은 MyJSFunction() –

+0

업데이트 : LinkButton> –

+0

내가 뭘 찾고 있었는지 리피터 활성화 텍스트 상자를 만들기위한 "자바 스크립트 함수"입니다. (링크 버튼의 onclick) –

관련 문제