[英]Ajax tabContainer using GridView inside panel, one button outside of the tabContainer
[英]Ajax tabContainer using panel, one button outside of the tabContainer
我正在使用具有5個tapPanel的Ajax選項卡容器創建管理面板,並且在每個tapPanel中,我都有一個標准工具面板。 在每個面板中,我都有GridView來顯示添加的數據。 最后,我在Ajax tabContainer外部有一個“添加”按鈕。 如果允許,我將發布設計。 問題是,我不知道tabContainer的編碼。 我創建了10個方法,因此可以在單擊“添加”按鈕時調用它。
這是我的代碼不起作用。
namespace Admin_Panel
{
public partial class add : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Session["Page"] = "ADD";
}
protected void btnAddCat_Click(object sender, EventArgs e)
{
AjaxControlToolkit.TabContainer container = (AjaxControlToolkit.TabContainer)TabConAddInfo;
AjaxControlToolkit.TabPanel tcTabPanel = new AjaxControlToolkit.TabPanel();
if (tcTabPanel.HeaderText == "Splash")
{
addSplash();
lblMsgAdd.Text = "Added successfully";
}
else if (tcTabPanel.HeaderText == "Main Category")
{
addMainCat();
lblMsgAdd.Text = "Added successfully";
}
else if (tcTabPanel.HeaderText == "Sub Category")
{
addSubCat();
lblMsgAdd.Text = "Added successfully";
}
else if (tcTabPanel.HeaderText == "Business Contact")
{
addBusinessContact();
lblMsgAdd.Text = "Added successfully";
}
else if (tcTabPanel.HeaderText == "Person Contact")
{
addPersonContact();
lblMsgAdd.Text = "Added successfully";
}
}
Int32 fileLength = 0;
string connStr = WebConfigurationManager.ConnectionStrings["connection"].ConnectionString;
private void addSplash()
{
HttpPostedFile uploadFile = FileLogo.PostedFile;
fileLength = uploadFile.ContentLength;
if (fileLength == 0)
{
string filePath = Server.MapPath(@"\style\img\no-photo-icon.jpg");
string fileName = Path.GetFileName(filePath);
FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read);
fileLength = (Int32)fs.Length;
Byte[] fileByteArr = new Byte[fileLength];
fs.Read(fileByteArr, 0, fileLength);
SqlConnection conn = new SqlConnection(connStr);
SqlCommand cmd = new SqlCommand("insert into SPLASH (VersionNumber, SplashLabel,LoginID) values (@VersionNumber,@SplashLabel,@LoginID)", conn);
cmd.Parameters.AddWithValue("@VersionNumber", txtVnum.Value);
cmd.Parameters.AddWithValue("@SplashLabel", txtSpLabel.Value);
cmd.Parameters.AddWithValue("@LoginID", txtYourID.Value);
cmd.Parameters.AddWithValue("@ImageData", fileByteArr);
cmd.Parameters.AddWithValue("@ImageContentType", "image/jpg");
cmd.Parameters.AddWithValue("@ImageSize", fileLength);
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
conn.Dispose();
cmd.Dispose();
}
else
{
Byte[] fileByteArray = new Byte[fileLength];
Stream streamObject = uploadFile.InputStream;
streamObject.Read(fileByteArray, 0, fileLength);
SqlConnection conn = new SqlConnection(connStr);
SqlCommand cmd = new SqlCommand("insert into SPLASH (VersionNumber, SplashLabel,LoginID) values (@VersionNumber,@SplashLabel,@LoginID)", conn);
cmd.Parameters.AddWithValue("@VersionNumber", txtVnum.Value);
cmd.Parameters.AddWithValue("@SplashLabel", txtSpLabel.Value);
cmd.Parameters.AddWithValue("@LoginID", txtYourID.Value);
cmd.Parameters.AddWithValue("@ImageData", fileByteArray);
cmd.Parameters.AddWithValue("@ImageContentType", "image/jpg");
cmd.Parameters.AddWithValue("@ImageSize", fileLength);
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
conn.Dispose();
cmd.Dispose();
}
}
private void showSplash()
{
SqlConnection conn = new SqlConnection(connStr);
SqlCommand cmd = new SqlCommand("select * from SPLASH", conn);
conn.Open();
SqlDataReader rdr = cmd.ExecuteReader();
System.Data.DataTable dt = new System.Data.DataTable();
dt.Load(rdr);
GridViewAddSplash.DataSource = dt;
GridViewAddSplash.DataBind();
conn.Close();
conn.Dispose();
cmd.Dispose();
}
private void addMainCat()
{
}
private void showMainCat()
{
}
private void addSubCat()
{
}
private void showSubCat()
{
}
private void addBusinessContact()
{
}
private void showBusinessContact()
{
}
private void addPersonContact()
{
}
private void showPersonContact()
{
}
}
}
我的另一個相關問題,如何為Ajax tab創建ActiveTabChanged容器Active_TabChanged
int CurrentTab = TabConAddInfo.ActiveTabIndex;
switch (CurrentTab)
{
case 0:
addSplash();
lblMsgAdd.Text = "Added successfully";
break;
}
etc. You would include that in your btn click event. Obviously I don't know if your TabIndex of zero is the right one to call addSplash() - just call the correct function for each tab.
至於制表符的更改-您是在談論提高javascript功能嗎?
OnClientActiveTabChanged="yourfunction";
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.