|
Suppose i have a server side method called Update() and i have one dropdown. when user select any element from dropdown then how could i call the server side method Update() by __doPostBack().
is it possible to call directly the method Update() by __doPostBack() if so then please help me with a sample code.
Thanks in advance.
tbhattacharjee
|
|
|
|
|
Tridip Bhattacharjee wrote: is it possible to call directly the method Update() by __doPostBack()
Directly No. but you can call any button event in __doPostBack().
So make hidden button any call it by __doPostBack() and in this event call your Update() method.
Viral
|
|
|
|
|
Check This Example:
.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="test-file-upload1.aspx.cs" Inherits="test_file_upload1" %>
<!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>Untitled Page</title>
<script language="javascript" >
function PostBack(t)
{
__doPostBack('Test',t.value);
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:DropDownList ID="DropDownList1" AutoPostBack="true" runat="server">
<asp:ListItem Value="1">1</asp:ListItem>
<asp:ListItem Value="2">2</asp:ListItem>
<asp:ListItem Value="3">3</asp:ListItem>
<asp:ListItem Value="4">4</asp:ListItem>
</asp:DropDownList>
</div>
</form>
</body>
</html>
.cs
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
public partial class test_file_upload1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
DropDownList1.Attributes.Add("onchange", "PostBack(this);");
if (IsPostBack)
{
string strControlName = "";
strControlName = Request.Params.Get("__EVENTTARGET");
if (strControlName == "Test")
{
string strArgument = "";
strArgument = Request.Params.Get("__EVENTARGUMENT");
Update(strArgument);
}
}
}
private void Update(string strTest)
{
Response.Write("You have selectecd: " + strTest);
}
}
|
|
|
|
|
Hi all,
Im adding a image for banner.That image is a flash gif image . if i add that image the image doesnt produce the flash effect , what would be the reason.
<asp:LinkButton ID="LnkImage" runat="server" CommandArgument='<%#DataBinder.Eval(Container.DataItem,"Owner_Id") %>'
CommandName="SongView">
<img src='<%#DataBinder.Eval(Container.DataItem,"uploadedphoto_id") %>' id="ImgAlbum"
runat="server" width="70" style="border: 0" height="70" /></asp:LinkButton>
|
|
|
|
|
Someone can help me, how to set height and width dynamically?
i try dis code
<script type="text/javascript">
function setSize(elem)
{
//find the height of the internal page
var the_height= elem.contentWindow.document.body.scrollHeight;
var the_width= elem.contentWindow.document.body.scrollWidth;
//change the height of the iframe
elem.height= the_height;
elem.width= the_width;
//alert(the_width);
}
</script>
<iframe id="Iframe1" src="Login.aspx" onload="setSize(this)" style="background-color: transparent" scrolling="no"></iframe>
iframe height function perfectly in ff,ie and chrome but iframe width not functioning in ff any one can help me?
|
|
|
|
|
how i change this code so that my code works
protected void DropDownList1_TextChanged(object sender, EventArgs e)
{
cnx.Open();
SqlCommand ddlcmd = new SqlCommand();
SqlDataSource1.SelectCommand = "SELECT max (Coupon_Info.Serial_End) AS SerialEnd FROM Coupon_Info INNER JOIN CouponType ON Coupon_Info.Coupon_TypeID = CouponType.CouponTypeID where CouponType.CouponName=" + DropDownList1.SelectedValue;
TextBox1.DataBind();
}
|
|
|
|
|
Where is error on your code? Do you get error message?
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
www.aktualiteti.com
|
|
|
|
|
I have a datareader and i am passing many strings one by one to a sub. I think i have to do dynamically but how can i do it.
The data looks like this
datetimestart
datetimeend
String
String
cboStringM
i don't know the data in adv.. i am looping thru one by one. i don't know how many strings i will encounter. i can encounter 3 or 4 or 1 but i need to display the textbox for each string i pass and same goes for the listbox.
When i pass the datetimestart i show the calendar control.
When i pass the datetimeend i show another calendar control.
When i pass the String i show the textbox.
When i pass the second String i show another textbox.
when cboStringM then a listbox
But the second textbox is not showing. When the first string is passed the firsttextbox is set to true when when the second strings turn comes the firsttextbox is already true and it doesn't go to the second one.
That is my problem. How can i show both the textboxes when 2 strings are passed of the same name.
here is the code
Dim ParameterReportType As New Data.SqlClient.SqlParameter("@id", SqlDbType.VarChar, 50)
ParameterReportType.Value = Request.QueryString("id")
myCommandReportType.Parameters.Add(ParameterReport Type)
Dim objReaderparam As SqlDataReader = myCommandReportType.ExecuteReader()
Dim DisplayedName As New ArrayList
Dim ParameterType As New ArrayList
Dim ParameterName As New ArrayList
Dim DataSource As New ArrayList
Dim Hidden As New ArrayList
Dim DefaultValue As New ArrayList
Dim DatabaseSourceNumber As New ArrayList
While objReaderparam.Read()
DisplayedName.Add(objReaderparam.Item("DisplayedNa me"))
ParameterType.Add(objReaderparam.Item("Parameterty pe"))
ParameterName.Add(objReaderparam.Item("ParameterNa me"))
DataSource.Add(objReaderparam.Item("DataSource"))
Hidden.Add(objReaderparam.Item("Hidden"))
DefaultValue.Add(objReaderparam.Item("DefaultValue "))
DatabaseSourceNumber.Add(objReaderparam.Item("Data baseSourceNumber"))
formattable(objReaderparam.Item("DisplayedName"), (objReaderparam.Item("Parametertype")), (objReaderparam.Item("ParameterName")), (objReaderparam.Item("DataSource")), (objReaderparam.Item("Hidden")), (objReaderparam.Item("DefaultValue")), (objReaderparam.Item("DatabaseSourceNumber")))
End While
objReaderparam.Close()
Sub formattable(ByVal DisplayedName As String, ByVal Parametertype As String, ByVal ParameterName As String, ByVal DataSource As String, ByVal Hidden As String, ByVal DefaultValue As String, ByVal DatabaseSourceNumber As String)
If Parametertype = "datetimestart" Then
Calendar1.Visible = True
End If
If Parametertype = "datetimeend" Then
Calendar2.Visible = True
End If
If Parametertype = "date" Then
Calendar1.Visible = True
End If
If Parametertype = "cboStringM" Then
DataSource = Right(DataSource, Len(DataSource) - 1)
Response.Write(DataSource)
Dim MyDataAdapter As SqlClient.SqlDataAdapter
MyDataAdapter = New SqlClient.SqlDataAdapter(test, conntest)
Dim dataSet As DataSet = New DataSet
MyDataAdapter.Fill(dataSet)
Dim dt As DataTable = dataSet.Tables(0)
ListBox1.DataSource = dt
ListBox1.DataTextField = dt.Columns(0).ColumnName
ListBox1.DataValueField = dt.Columns(1).ColumnName
ListBox1.DataBind()
ListBox1.Visible=True
End If
If Parametertype = "String" Then
TextBox1.Visible = True
End If
end sub
<asp:Calendar ID="Calendar1" runat="server" Visible="False"></asp:Calendar><br /><br /><br />
<asp:Calendar ID="Calendar2" runat="server" Visible="False"></asp:Calendar>
<asp:ListBox ID="ListBox1" runat="server" Visible="False" SelectionMode="Multiple"
></asp:ListBox>
<asp:TextBox ID="TextBox1" runat="server" Visible="False"></asp:TextBox><br /><br />
<asp:TextBox ID="TextBox2" runat="server" Visible="False"></asp:TextBox><br /><br />
modified on Wednesday, July 29, 2009 6:53 PM
|
|
|
|
|
I do not understand why but the code I am writing does not raise the refered event_handler, here is my code where do you think I am mistaken?
if (linkb > 1)
{
for (int i = 1; i <= linkb; i++)
{
LinkButton bottomLink = new LinkButton();
LiteralControl bottomLiteral = new LiteralControl(" ");
bottomLink.Text = i.ToString();
pnlBottom.Controls.Add(bottomLink);
pnlBottom.Controls.Add(bottomLiteral);
bottomLink.Click += new EventHandler(this.changeLink);
}
|
|
|
|
|
Dynamically added controls need to be added before page load ( not in page load, before it ), for viewstate to be restored. Otherwise, events will not fire.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
YOu mean to add manually or is there another event that is fired before page-load?
|
|
|
|
|
Hi All.
I have designed a small app Which contains a Master Page and 4 child pages,
Now I have designed a command tab, (collection of buttons) in Master Page,
Now,, when I load 1st child page, say. Produts.aspx, and i press on Retrieve button of master page, all the products should be retrieved, and if I want to navigate, it should also be possible, and if I want to remove then deletion of a particular product should also be done. But all these operations buttons are in master page.
the operation should be done based on the subsequent child page.
How can i do this?
Thanks in Advance.
|
|
|
|
|
Master page
public partial class MyMasterPage : System.Web.UI.MasterPage<br />
{<br />
public event EventHandler<EventArgs> OnSave;<br />
<br />
protected void Page_Load(object sender, EventArgs e)<br />
{<br />
Save.Click += new EventHandler(OnButtonClick);<br />
}<br />
<br />
public void OnButtonClick(object sender, EventArgs e) <br />
{<br />
EventHandler<EventArgs> tmp = null;<br />
if(tmp != null)<br />
{<br />
tmp(sender, e);<br />
}<br />
}
Content base page
((MyMasterPage)Master).OnSave += new EventHandler<EventArgs>(OnSave);<br />
protected virtual void OnSave(object sender, EventArgs e){}
Content page
protected override void OnSave(object sender, EventArgs e)<br />
{<br />
<br />
}
only two letters away from being an asset
|
|
|
|
|
Thanks for the Solution.
But What is Content base page and content page.?
I have implement everything regarding master page?
Now what to do?
?
thanks again.
|
|
|
|
|
BhavinBhatt wrote: Now what to do?
Read[^]
only two letters away from being an asset
|
|
|
|
|
Still Cant understand that where to put the following
((MyMasterPage)Master).OnSave += new EventHandler<EventArgs>(OnSave);
protected virtual void OnSave(object sender, EventArgs e){}
|
|
|
|
|
Hi i am a student and i want to develop a college application for windows mobile and iPhone mobile. Can i develop this application by using asp.net and what specific tool in asp.net that i have to use if we can develop the application . If not can you propose me the language and the front end and the back end needed for that language
|
|
|
|
|
shankarbuddhi wrote: Hi i am a student and i want to develop a college application for windows mobile and iPhone mobile. Can i develop this application by using asp.net
You want to developed Windows/Mobile Application using ASP.net ?
shankarbuddhi wrote: what specific tool in asp.net
shankarbuddhi wrote: If not can you propose me the language and the front end and the back end needed for that language
It seems you don't have basic idea that what you are trying to do.
I have few suggestio for you.
1. First Understand yourself that what you are trying to do ? what is requirment? What is the purpose ?
2. If you are really interested with .NET, Buy some Basic book of .net and Start Reading.
3. Try to practice as much as you can.
4. Then decide project on particular technology.
If stuck while learning or doing some project, come over here. Everybody will help you
Best of Luck !!
|
|
|
|
|
Yes, you can. Because, if they are mobiles, they will be online, you can write a website and then any phone with a browser will be able to see it. However, if that's viable, depends on the nature of the application.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
hi all,
on firefox this code work well ....but this not working on IE.....why?
for(var i =0 ;i< result.length;i++)
{
var obj = result[i];
var sel = document.getElementById("Select"+obj.LoginId);
sel.value =obj.Skin;
}
|
|
|
|
|
zeeShan anSari wrote: but this not working on IE.....
What do you mean by not working ? Are you getting any particular error ?
|
|
|
|
|
sel.value =obj.Skin; --> here obj.Skin is not assign in sel.Value
here sel is select
ok.... let's suppose
<select id="Select'+obj.LoginId+'" class="Select"><option>LightBlue</option><option>SeaGreen</option><option>Orange</option></select>
and now
var sel = document.getElementById('LoginId1');
sel.options.value ="SeaGreen";
but sel is still not selected in IE
thanks
modified on Wednesday, July 29, 2009 11:41 AM
|
|
|
|
|
for(var i =0 ;i< result.length;i++)
{
var obj = result[i];
this is solution :)
var sel = document.getElementById("Select"+obj.LoginId);
switch(obj.Skin)
{
case 'LightBlue':
{
sel.options[0].selected=true;
break;
}
case 'SeaGreen':
{
sel.options[1].selected=true;
break;
}
case 'Orange':
{
sel.options[2].selected=true;
break;
}
is it good logic?
|
|
|
|
|
You need to write some debugging code to work out what is not working in IE. It's not uncommon to have to write script that works out what browser you are in, because of differences in the js language implimentations.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Dear All,
Good Day.
i just want to know how to add buttonColumn Manually in to my gridview or datatable and manage all properties such as visible , forecolor .... etc by coding
i tried to add buttoncollumn to datatable , gridview but it accures erorrs
find my code :
Dim bc As New ButtonColumn()
bc.CommandName = "add"
bc.HeaderText = "Event Details"
bc.Text = "Details"
bc.ButtonType = ButtonColumnType.PushButton
GridView1.Columns.Add(bc) 'error here
thank you in advance for your support
best regards,,,
|
|
|
|