|
Hi ToddHileHoffer
ToddHileHoffer wrote: Double click the button in design view to get your method. Put your server code there.
Here actually you are directly adding a server side event handler. This implicitly calls _doPostback function of with proper eventTarget and _eventArgument value.
ToddHileHoffer wrote: Button1.click();
ToddHileHoffer wrote: use the callServerEvent() method in your javascript code.
If I add this callServerEvent() method also, from where you want to call this javascript function so that you epect to fire server side event !!! ???
Thanks,
Arindam D Tewary
|
|
|
|
|
Arindam Tewary wrote: Here actually you are directly adding a server side event handler. This implicitly calls _doPostback function of with proper eventTarget and _eventArgument value.
Yes. This is a very easy way of doing this.
Arindam Tewary wrote: If I add this callServerEvent() method also, from where you want to call this javascript function so that you epect to fire server side event !!! ???
You can use callServerEvent() in your javascript code anywhere you want.
And as an added bonus. If you put the Button1 inside an ajax panel your server event will fire via ajax and the page will not postback!
I put together an example for you.
<br />
<br />
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %><br />
<br />
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><br />
<html xmlns="http://www.w3.org/1999/xhtml"><br />
<head runat="server"><br />
<title></title><br />
<br />
<script type="text/javascript" ><br />
function callServerEvent() {<br />
<br />
var Button1 = document.getElementById("<%= Button1.ClientID %>");<br />
Button1.click();<br />
}<br />
<br />
</script><br />
<br />
<script type="text/C#" runat="server"><br />
protected void Page_Load(object sender, EventArgs e)<br />
{<br />
if (!IsPostBack)<br />
{<br />
this.Button1.Style.Add("display", "none");<br />
}<br />
}<br />
protected void Button1_Click(object sender, EventArgs e)<br />
{<br />
this.lblResult.Text = "Server code executed at " + DateTime.Now.ToLongTimeString();<br />
}<br />
</script><br />
</head><br />
<body><br />
<form id="form1" runat="server"><br />
<asp:ScriptManager ID="ScriptManager1" runat="server"><br />
</asp:ScriptManager><br />
<div><br />
<br /><br />
This is an example of an easy way to call a server method from javascript.<br />
<br /><br />
<br /><br />
<asp:UpdatePanel ID="UpdatePanel1" runat="server"><br />
<ContentTemplate><br />
<asp:Label runat="server" ID="lblResult"></asp:Label><br />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" /><br />
</ContentTemplate><br />
</asp:UpdatePanel><br />
</div><br />
</form><br />
<p><br />
</p><br />
<p><br />
<input id="Button2" type="button" value="Call Server Code From Javascript" onclick="callServerEvent();" /></p><br />
</body><br />
</html><br />
<br />
I didn't get any requirements for the signature
modified on Thursday, April 16, 2009 10:25 AM
|
|
|
|
|
Hi
I tried your instruction but not sure whether I have exactly been able to achieved that ,
here is my code ,
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
</div>
<script language="javascript">
function callServerEvent()
{
var Button1 = document.getElementById("<%= Button1.ClientID %>");
Button1.click();
}
</script>
</form>
</body>
</html>
See here, I didnt call this javascript function "callServerEvent()" from anywhere.
So I guess, thats not gets called at all.
If so how we have called the server side event handler from client side code?
Please comment on this if I am missing anything !!!
Thanks,
Arindam D Tewary
|
|
|
|
|
I edited the post above this with an example. Does that make sense?
I didn't get any requirements for the signature
|
|
|
|
|
This is really very strange that you are actually calling "Button1_Click" which is a server side event handler of "Button1" with so much hassle. You are calling Button1's event handler by Clikcing (firing client side event handler of Button2) "Button2". This is really not proper at all.
The whole thing which you have shown is equivalent to just clicking a server side asp.net button(yes as simple as that )
and a server side asp.net button actually calls the same _doPostback internally ( you never need to know that, actually when you use asp.net server side button !!! )
I am really not getting you theory at all !!!
Please correct me if I am wrong ....
Thanks,
Arindam D Tewary
|
|
|
|
|
You are correct in that you would never do what I just did, it would be pointless. The point was to show how to call server code from javascript. The idea here is that you can call the server code without a control.
Now he can do it. The code below would execut the server code in the Button1_Click event.
gridview.Cells[index].Attributes.Add("ondblclick". "callServerEvent();");
Another example: say you are using the modal popup window in the ajax toolkit and you want to update your form when the window is closed.
You could set OnOkScript="callServerEvent();" and then you can run server side code when your window is closed.
I didn't get any requirements for the signature
|
|
|
|
|
when we create project just choosing option like Web Site project then dll is not created until we publish the whole site. so please tell me in which situation a user should choose Web Site project and why the dll file is not create if user choose Web Site project type.
tbhattacharjee
|
|
|
|
|
Check this MSDN[^] article.
|
|
|
|
|
hi to all
how can i get the client id in .net
html source:
<input type="button" id="button1" class="buttonsT" name="inputval30something^&()%#@!sabs" value="30 Something(1494)" title="Click this Button to log in as 30 Something(1494)" onclick="loginas('30something^&()%#@!sabs');">
this entirly bind in xslt..not in html
Known Is Drop.Unknown Is Ocean
|
|
|
|
|
saravanan05 wrote: how can i get the client id in .net
var id= document.getElementById(button1);
cheers,
Abhijit
CodeProject MVP
|
|
|
|
|
hi thanks for reply
hidden field:
<input name="hd1" id="hd1" type="hidden" />
jsscript:
function test()
{
// document.forms.tstformfortavern.hd1.value=document.getElementById("button1");
document.getElementById("hd1").value=document.getElementById("button1").id;
alert(document.getElementById("hd1").value);
}
i try get value in hdn.value in codebehind.but i didnt get value
rs
sara
Known Is Drop.Unknown Is Ocean
|
|
|
|
|
saravanan05 wrote: i try get value in hdn.value in codebehind.but i didnt get value
What is hdn? Do you mean hd1? Your control is not marked as runat=server and how are you expecting to read it's value from code behind?
|
|
|
|
|
Make Hidden Field as Server Side Control
<input type="hidden" runat="server" id="hdn" />
Here is the java script
script language="javascript" type="text/javascript">
var hdnid="<%= hdn.ClientID%>"
function test()
{
var v= document.getElementById('btn1');
document.getElementById(hdnid).Value =v.value;
alert( document.getElementById(hdnid).Value);
}
</script>
Now you can use hdn.value in codebehind also.
cheers,
Abhijit
CodeProject MVP
|
|
|
|
|
thanks for reply Abhijit
For example:
i get client id button1 in codebehind
I need to set button back color using this button1 id..
Is this possible?
Known Is Drop.Unknown Is Ocean
|
|
|
|
|
I am checking my site in both IE & Mozilla Firefox.
There is a simple hyperlink which is working in IE but not in mozilla
I have used ajax to call the page where hyperlink is given.
|
|
|
|
|
In firefox there is "Error Console" which is great help for debugging any client side problem that occurs in using Mozila. You can try out that and please let us know that what exactly the problem is !!! It will easier for all to help you ...
Thanks,
Arindam D Tewary
|
|
|
|
|
thnx for your reply.
I checked that also, but there is no error.
|
|
|
|
|
Hi
if anyone could please give me pointers on how to do this if it's possible
I have a textbox and a button next to each other , now the user needs to click on the button to fill the textbox with a certain value. Now on the validation side , if the textbox has no value the requiredfield validator will give it's message calling the ValidatorCalloutExtender giving that ajax popup.
Now till there it's easy enough, but the thing is I need to display the ValidatorCalloutExtender pointing at the button and not the textbox.
Please help on this...
|
|
|
|
|
|
Please continue with the same thread, rather than starting a new one, I will really confused to all.
Thanks !!
cheers,
Abhijit
CodeProject MVP
|
|
|
|
|
I have to prepare income-expenditure report.Both income and expenditure from logically different tables.I have to show like this:
income expenditure
------ ------------
--------- -------
Can it be shown in gridview?OR do i have to use other control please explain in detail
|
|
|
|
|
There are multiple way to display reports. You have to write simple SQL SP'S which will return you the required output, the Display it on GridView or Repeater Control . Even you can use XSL to render it on your page.
cheers,
Abhijit
CodeProject MVP
|
|
|
|
|
What defines the income / expenditure to be on the same line ?
Is it a date? For example: April 15th, 2009: Income: $500, Expense: $200
Also, is there always a match between income and expense on the same day?
Example 2: May 1: Income $200, no expense or No income, $50 expense.
This would determine how the SQL query is structured.
|
|
|
|
|
Hi
I caught in problem since 3 days. Try lot of stuff not able to solve the problem. I developed a form for inventory project - Product.aspx. It has option to add category, subcategory, company on the fly just clicking the add new button. When user press add new, pop appears to ask information and theres save button.
Save button has code to save all data in database tables. But click event do not fire for all these buttons. Look at the form: http://www.artinarts.in/ecomm/admin/product.aspx. Dont know where's the problem.
I read some-where remove all validators and remove un-neccessary updatepanels. I did same but no use. I also read somewhere use aync="true" in page directive. still it not work. I also read that use <triggers> in update panel still not successfull. Please guide me what to do.
My Product.aspx file is as:
<%@ Page Title="" Language="VB" MasterPageFile="MasterPage.master" AutoEventWireup="false" CodeFile="Product.aspx.vb" Inherits="admin_Product" Async="true" %>
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<style type="text/css">
.style1
{
width: 105%;
}
.style7
{
width: 89px;
}
.style8
{
width: 279px;height: 30px;
}
.style9
{
width: 304px;height: 30px;
}
.style11
{
width: 123px;
}
.style12
{
height: 30px;
}
.style14
{
width: 304px;
}
.style15
{
width: 279px;
}
</style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<br />
<h3 style="font-family:Verdana" id="lblNoProducts">
Add new Product</h3>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<table class="style1">
<tr>
<td valign="top" class="style15">
Category</td>
<td valign="top" class="style14">
<asp:DropDownList ID="lstCategory" runat="server" AutoPostBack="True">
<asp:ListItem>Primary</asp:ListItem>
</asp:DropDownList>
</td>
<td valign="top">
<asp:Button ID="Button1" runat="server" Text="New Category" Height="23px"
Width="121px" UseSubmitBehavior="False" />
<cc1:PopupControlExtender ID="Button1_PopupControlExtender" runat="server"
TargetControlID="Button1" PopupControlID="pnlCategory" Position ="Right"
>
</cc1:PopupControlExtender>
<asp:Panel ID="pnlCategory" Width="396px" Height="59px" runat="server"
BackColor="LightYellow">
Category :
<asp:TextBox ID="txtCategory" runat="server" MaxLength="20"></asp:TextBox>
<asp:Label ID="lblCatError" runat="server" ForeColor="#FF3300"></asp:Label>
<br />
<asp:Button ID="Button2" runat="server"
Text="Save" OnClick="Button2_Click" />
</asp:Panel>
</td>
</tr>
<tr>
<td class="style15" valign="top">
Sub Category</td>
<td class="style14" valign="top">
<asp:DropDownList ID="lstSubCategory" runat="server">
<asp:ListItem>Primary</asp:ListItem>
</asp:DropDownList>
</td>
<td>
<asp:Button ID="Button3" runat="server" Text="New Sub-category" Height="24px"
Width="122px" UseSubmitBehavior="False" />
<cc1:PopupControlExtender ID="Button3_PopupControlExtender" runat="server"
TargetControlID="Button3" PopupControlID="pnlSubCategory"
Position ="Right">
</cc1:PopupControlExtender>
<asp:Panel ID="pnlSubCategory" Width="440px" Height="82px" runat="server"
BackColor="LightYellow">
<table class="style1">
<tr>
<td class="style7">
Category</td>
<td>
<asp:DropDownList ID="drpCat" runat="server">
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="style7" valign="top">
Sub-Category</td>
<td valign="top">
<asp:TextBox ID="txtSubCat" runat="server" MaxLength="20"></asp:TextBox>
<asp:Label ID="lblSubCatError" runat="server" ForeColor="#FF3300"></asp:Label>
<br />
<asp:Button ID="Button5" runat="server" Height="23px" Text="Save" />
</td>
</tr>
</table>
</asp:Panel>
</td>
</tr>
<tr>
<td class="style8" valign="top">
Company</td>
<td class="style9" valign="top">
<asp:DropDownList ID="lstCompany" runat="server">
<asp:ListItem>Primary</asp:ListItem>
</asp:DropDownList>
</td>
<td class="style12" valign="top">
<asp:Button ID="Button6" runat="server" Height="23px" Text="New Company"
Width="126px" UseSubmitBehavior="False" />
<cc1:PopupControlExtender ID="Button6_PopupControlExtender" runat="server"
DynamicServicePath="" Enabled="True" ExtenderControlID="" Position ="Right"
TargetControlID="Button6" PopupControlID="pnlCompany">
</cc1:PopupControlExtender>
<asp:Panel ID="pnlCompany" Width="460px" Height="187px" runat="server"
BackColor="LightYellow">
<table class="style1">
<tr>
<td class="style7">
Company</td>
<td class="style11">
<asp:TextBox ID="txtCompany" runat="server" MaxLength="20"></asp:TextBox>
</td>
<td>
<asp:Label ID="lblCompError" runat="server" ForeColor="#FF3300"></asp:Label>
</td>
</tr>
<tr>
<td class="style7">
Address</td>
<td class="style11">
<asp:TextBox ID="txtCAddress" runat="server" MaxLength="50"></asp:TextBox>
</td>
<td>
</td>
</tr>
<tr>
<td class="style7">
City</td>
<td class="style11">
<asp:TextBox ID="txtCity" runat="server" MaxLength="20"></asp:TextBox>
</td>
<td>
</td>
</tr>
<tr>
<td class="style7">
State</td>
<td class="style11">
<asp:TextBox ID="txtState" runat="server" MaxLength="20"></asp:TextBox>
</td>
<td>
</td>
</tr>
<tr>
<td class="style7">
Contact No</td>
<td class="style11">
<asp:TextBox ID="txtContact" runat="server" MaxLength="15"></asp:TextBox>
</td>
<td>
</td>
</tr>
<tr>
<td class="style7">
Email</td>
<td class="style11">
<asp:TextBox ID="txtEmail" runat="server" MaxLength="25"></asp:TextBox>
</td>
<td>
</td>
</tr>
</table>
<asp:Button ID="Button7" runat="server"
Text="Save" Height="24px" Width="58px" />
</asp:Panel>
</td>
</tr>
<tr>
<td class="style15" valign="top">
Price</td>
<td class="style14" valign="top">
<asp:TextBox ID="txtPrice" runat="server" MaxLength="10"></asp:TextBox>
</td>
<td>
Currency:
<asp:DropDownList ID="lstCurrency" runat="server" Font-Size="10pt">
<asp:ListItem>INR</asp:ListItem>
<asp:ListItem>USD</asp:ListItem>
<asp:ListItem>EURO</asp:ListItem>
<asp:ListItem>UK POUND</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="style15" valign="top">
Product</td>
<td class="style14" valign="top">
<asp:TextBox ID="txtProduct" runat="server" MaxLength="70"></asp:TextBox>
</td>
<td>
</td>
</tr>
<tr>
<td class="style15" valign="top">
Opening Stock</td>
<td class="style14" valign="top">
<asp:TextBox ID="txtOpnStock" runat="server">0</asp:TextBox>
</td>
<td>
</td>
</tr>
<tr>
<td class="style15" valign="top">
Unit of Measurement</td>
<td class="style14" valign="top">
<asp:DropDownList ID="lstUnits" runat="server">
<asp:ListItem>Number</asp:ListItem>
<asp:ListItem>KG</asp:ListItem>
<asp:ListItem>Gram</asp:ListItem>
<asp:ListItem>ML</asp:ListItem>
<asp:ListItem>Litre</asp:ListItem>
<asp:ListItem>Box</asp:ListItem>
</asp:DropDownList>
</td>
<td>
<asp:Button ID="Button10" runat="server" Text="Add New"
UseSubmitBehavior="False" />
<cc1:PopupControlExtender ID="Button10_PopupControlExtender" runat="server"
DynamicServicePath="" Enabled="True" ExtenderControlID=""
TargetControlID="Button10" PopupControlID="pnlUM" Position="Right" >
</cc1:PopupControlExtender>
<asp:Panel ID="pnlUM" Width="460px" Height="57px" runat="server"
BackColor="LightYellow">
Unit:
<asp:TextBox ID="txtUnit" runat="server" MaxLength="10"></asp:TextBox>
<asp:Label ID="lblErrorUnit" runat="server" ForeColor="#FF3300"></asp:Label>
<br />
<asp:Button ID="Button11" runat="server" Text="Save" />
</asp:Panel>
</td>
</tr>
<tr>
<td class="style15" valign="top">
Description</td>
<td class="style14" valign="top">
<asp:TextBox ID="txtDescription" runat="server"></asp:TextBox>
</td>
<td>
</td>
</tr>
<tr>
<td class="style15" valign="top">
Upload Big Image<br />
(500 X 500 px)</td>
<td class="style14" valign="top">
<asp:FileUpload ID="FileUpload1" runat="server" />
</td>
<td valign="top">
</td>
</tr>
<tr>
<td class="style15" valign="top">
Upload Thumbnail<br />
(100 X 100 px)</td>
<td class="style14" valign="top">
<asp:FileUpload ID="FileUpload2" runat="server" />
</td>
<td valign="top">
</td>
</tr>
<tr>
<td class="style15" valign="top">
Weight</td>
<td class="style14" valign="top">
<asp:TextBox ID="txtWeight" runat="server"></asp:TextBox>
</td>
<td>
</td>
</tr>
<tr>
<td class="style15" valign="top">
Weight-Unit</td>
<td class="style14" valign="top">
<asp:DropDownList ID="lstWgUnit" runat="server">
<asp:ListItem>Number</asp:ListItem>
<asp:ListItem>KG</asp:ListItem>
<asp:ListItem>Gram</asp:ListItem>
<asp:ListItem>ML</asp:ListItem>
<asp:ListItem>Litre</asp:ListItem>
<asp:ListItem>Box</asp:ListItem>
</asp:DropDownList>
</td>
<td>
<asp:Button ID="Button12" runat="server" Text="New Unit"
UseSubmitBehavior="False" />
<cc1:PopupControlExtender ID="Button12_PopupControlExtender" runat="server"
DynamicServicePath="" Enabled="True" ExtenderControlID=""
TargetControlID="Button12" PopupControlID="pnlUMW" >
</cc1:PopupControlExtender>
<asp:Panel ID="pnlUMW" Width="460px" Height="57px" runat="server"
BackColor="LightYellow">
Unit:
<asp:TextBox ID="txtUnitW" runat="server" MaxLength="10"></asp:TextBox>
<asp:Label ID="lblErrorUnitW" runat="server" ForeColor="#FF3300"></asp:Label>
<br />
<asp:Button ID="Button13" runat="server" Text="Save" />
</asp:Panel>
</td>
</tr></table>
<table width="100%">
<tr>
<td class="style15" valign="top">
<asp:LinkButton ID="LinkButton1" runat="server">Show List</asp:LinkButton>
<cc1:PopupControlExtender ID="LinkButton1_PopupControlExtender" runat="server"
DynamicServicePath="" Enabled="True" ExtenderControlID="" Position ="Bottom"
TargetControlID="LinkButton1" PopupControlID="pnlGrid">
</cc1:PopupControlExtender>
<asp:Button ID="Button8" runat="server" Text="Add to List"
ValidationGroup="prd" />
<asp:Panel ID="pnlGrid" runat="server" Height="300" Width="500" BackColor="LightYellow">
<asp:GridView ID="GridView1" runat="server" Width="544px">
<Columns>
<asp:CommandField ShowDeleteButton="True" />
</Columns>
<EmptyDataTemplate>
There is no product in the list at present
</EmptyDataTemplate>
</asp:GridView>
</asp:Panel>
</td>
<td class="style14" valign="top">
</td>
<td>
</td>
</tr>
</table>
<p>
</p>
<p>No of Products added:
<asp:Label ID="lblNoItems" runat="server" Text="0"></asp:Label>
</p>
<p>
</p>
<p style="text-align: center">
<asp:Button ID="Button9" runat="server" Text="Save All" Width="126px" />
</p>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="Button2" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="Button5" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="Button7" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="Button13" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
</asp:Content>
Code behind: Product.aspx.vb
Imports System.Data
Imports System.Data.SqlClient
Imports System.Linq
Partial Class admin_Product
Inherits System.Web.UI.Page
Shared productTable As New DataTable("Products")
Shared srNo As Integer = 0
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
On Error Resume Next
If Not IsPostBack Then
productTable.Columns.Add(New DataColumn("SrNo"))
productTable.Columns.Add(New DataColumn("Category"))
productTable.Columns.Add(New DataColumn("SubCategory"))
productTable.Columns.Add(New DataColumn("Company"))
productTable.Columns.Add(New DataColumn("Product"))
productTable.Columns.Add(New DataColumn("OpeningStock"))
productTable.Columns.Add(New DataColumn("UnitsMeasurement"))
productTable.Columns.Add(New DataColumn("Weight"))
productTable.Columns.Add(New DataColumn("WeightUnit"))
productTable.Columns.Add(New DataColumn("Description"))
productTable.Columns.Add(New DataColumn("BigImagePath"))
productTable.Columns.Add(New DataColumn("ThumbnailPath"))
productTable.Columns.Add(New DataColumn("Price"))productTable.Columns.Add(New DataColumn("Currency"))
Category.fillCategories(lstCategory)
Category.fillSubCategories(lstSubCategory, lstCategory.SelectedValue)
Company.fillCompanies(lstCompany)
Category.fillCategories(drpCat)
Product.fillUnits(lstUnits)
Product.fillUnits(lstWgUnit)
End If
End Sub
Protected Sub Button9_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button9.Click
If productTable.Rows.Count >= 1 Then
For i As Integer = 1 To productTable.Rows.Count - 1
If Not Product.save(productTable.Rows(i)("Product").ToString(), _
Company.getID(productTable.Rows(i)("Company").ToString()), _
Category.getID(productTable.Rows(i)("Category").ToString()), _
Category.getSubCatID(productTable.Rows(i)("SubCategory").ToString()), _
productTable.Rows(i)("UnitsMeasurement").ToString(), _
productTable.Rows(i)("Price").ToString(), productTable.Rows(i)("Currency").ToString(), _
productTable.Rows(i)("OpeniningStock").ToString(), _
productTable.Rows(i)("Description").ToString(), _
productTable.Rows(i)("BigImagePath").ToString(), _
productTable.Rows(i)("ThumbnailPath").ToString(), _
productTable.Rows(i)("WeightUnit").ToString(), _
productTable.Rows(i)("Weight").ToString()) Then
End If
Next
End If
End Sub
Protected Sub Button8_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button8.Click
srNo = srNo + 1
Dim dr As DataRow = productTable.NewRow
dr(0) = srNo
dr(1) = lstCategory.SelectedValue
dr(2) = lstSubCategory.SelectedValue
dr(3) = lstCompany.SelectedValue
dr(4) = txtProduct.Text.ToUpper()
dr(5) = txtOpnStock.Text
dr(6) = lstUnits.SelectedValue
dr(7) = txtWeight.Text
dr(8) = lstWgUnit.SelectedValue
dr(9) = txtDescription.Text
dr(10) = FileUpload1.FileName
dr(11) = FileUpload2.FileName
dr(12) = txtPrice.Text
dr(13) = lstCurrency.SelectedValue
productTable.Rows.Add(dr)
GridView1.DataSource = productTable
GridView1.DataBind()
lblNoItems.Text = GridView1.Rows.Count
End Sub
Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim errMessage As String = ""
If Category.Save(txtCategory.Text.ToUpper(), errMessage) Then
Category.fillCategories(lstCategory)
Category.fillCategories(drpCat)
txtCategory.Text = ""
Else
lblCatError.Text = errMessage
End If
End Sub
Protected Sub Button5_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button5.Click
Dim errMessage As String = ""
If Category.SaveSubCategory(drpCat.SelectedValue, txtSubCat.Text.ToUpper(), errMessage) Then
Category.fillSubCategories(lstSubCategory, lstCategory.SelectedValue)
txtSubCat.Text = ""
Else
lblSubCatError.Text = errMessage
End If
End Sub
Protected Sub Button7_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button7.Click
Dim errMessage As String = ""
If Company.Save(txtCompany.Text.ToUpper(), txtCAddress.Text.ToUpper(), txtCity.Text.ToUpper(), txtState.Text.ToUpper(), txtContact.Text.ToUpper(), txtEmail.Text.ToUpper(), errMessage) Then
Company.fillCompanies(lstCompany)
txtCAddress.Text = ""
txtCity.Text = ""
txtContact.Text = ""
txtEmail.Text = ""
txtState.Text = ""
txtCompany.Text = ""
Else
lblCompError.Text = errMessage
End If
End Sub
Protected Sub lstCategory_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles lstCategory.SelectedIndexChanged
Category.fillSubCategories(lstSubCategory, lstCategory.SelectedValue)
End Sub
Protected Sub GridView1_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GridView1.RowDeleting
productTable.Rows(e.RowIndex).Delete()
GridView1.DataSource = productTable
GridView1.DataBind()
End Sub
Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.SelectedIndexChanged
End Sub
Protected Sub Button11_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button11.Click
Dim errMessage As String = ""
If Product.SaveUnitMeasure(txtUnit.Text.ToUpper(), errMessage) Then
Product.fillUnits(lstUnits)
Product.fillUnits(lstWgUnit)
txtUnit.Text = ""
Else
lblErrorUnit.Text = errMessage
End If
End Sub
Protected Sub Button13_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button13.Click
Dim errMessage As String = ""
If Product.SaveUnitMeasure(txtUnitW.Text.ToUpper(), errMessage) Then
Product.fillUnits(lstUnits)
Product.fillUnits(lstWgUnit)
txtUnitW.Text = ""
Else
lblErrorUnit.Text = errMessage
End If
End Sub
End Class
Please help me to sort out the issue
|
|
|
|
|
Where you have hooked the event handlers? I can't see it on buttons markup. Also, don't dump your whole code. It makes the post unreadable. Please post only relevant part.
|
|
|
|