My Personal Blog's
Posts tagged ASP.NET
VB.NET – ASP.NET communication between user control and web page using event handler
Apr 21st
In this post, we want to show how button in user control communicate with web page in asp.net
First create user control called button.ascx.
Add 3 button, name it btnSave, btnEdit and btnCancel.
in button.ascx back code, add this code:
Public Partial Class button
Inherits System.Web.UI.UserControl
Public Event btnSaveHandler As System.EventHandler
Public Event btnEditHandler As System.EventHandler
Public Event btnCancelHandler As System.EventHandler
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
Protected Sub btnSave_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnSave.Click
RaiseEvent btnSaveHandler(Me, New EventArgs())
End Sub
Protected Sub btnEdit_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnEdit.Click
RaiseEvent btnEditHandler(Me, New EventArgs())
End Sub
Protected Sub btnCancel_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnCancel.Click
RaiseEvent btnCancelHandler(Me, New EventArgs())
End Sub
End Class
In Default.aspx, add 1 label called label1, then drag the button.ascx to the default.aspx.
Add code in default.aspx as below:
Partial Public Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Label1.Text = Request.QueryString("label")
AddHandler button1.btnCancelHandler, AddressOf cancelClick
AddHandler button1.btnEditHandler, AddressOf editClick
AddHandler button1.btnSaveHandler, AddressOf saveClick
End Sub
Private Sub cancelClick(ByVal sender As Object, ByVal e As EventArgs)
Response.Redirect("default.aspx?label=Cancel")
End Sub
Private Sub editClick(ByVal sender As Object, ByVal e As EventArgs)
Response.Redirect("default.aspx?label=Edit")
End Sub
Private Sub saveClick(ByVal sender As Object, ByVal e As EventArgs)
Response.Redirect("default.aspx?label=Save")
End Sub
End Class
Run it, you will see that button that we create in user control can be manipulate and used in default.aspx
See other example for communication between user control and page in:
http://www.codeproject.com/KB/user-controls/Page_UserControl.aspx
ASP.NET: How to read XML Data String to Dataset
Dec 2nd
The output of XML String:
<?xml version="1.0" encoding="utf-8" ?> - <NewDataSet> - <Table> <CONDOM>Durex</CONDOM> <SIZE>XL</SIZE> <QTY>123</QTY> <COLOR>616</COLOR> </Table> </NewDataSet>
In order to convert from XML to dataset, this is the code:
Read the rest of this entry »
ASP.NET: Convert String XML to XML Node
Dec 2nd
For example I have string value like this:
<?xml version="1.0"?>
<Product type="Condom">
<CondomName>durex</CondomName>
<ExpDate>False</ExpDate>
<Type>False</Type>
<Color>False</Color>
<Qty>False</Qty>
</Product>
Since this this is a string value, so we need to convert to xml node to be able to process.
So this is the code:
Read the rest of this entry »
ASP.NET: How to use Javascript alert inside AJAX UpdatePanel
Dec 2nd
Page. ClientScript.RegisterStartupScript(this.GetType(), "winPop", "alert('Update is successful')
ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), Guid.NewGuid().ToString(), "alert('Update is successfu.');",True)
ASP.NET – Convert CSV to Dataset
Jul 17th
In this post I will show you how to convert from .csv files to dataset in ASP.NET
Read the rest of this entry »
Read Excel Cell Value from ASP.NET 2008 – VB.NET
Jun 4th
In this article I will show how to read value from excel per cell,
First Im using FileUpload component from asp.net
<td>
<asp:FileUpload ID="uplFile" runat="server" Width="367px"/>
</td>




