Source File Code:
<script type="text/javascript">
function UploadImage()
{
document.getElementById('<%=BtnTemp.ClientID %>').click();
}
</script>
<asp:Image ID="Image1" runat="server" Height="97px" Width="130px" />
<asp:FileUpload ID="FileUpload1" OnChange="return UploadImage();" runat="server"
/>
<div id="hide" style="display:none">
<asp:Button ID="BtnTemp" runat="server" OnClick="BtnTemp_Click" />
</div>
.Cs file Code:
protected void BtnTemp_Click(object sender, EventArgs e)
{
string FileName = FileUpload1.FileName;
string GudID = Guid.NewGuid().ToString();
string fullname = GudID +"_"+ FileName;
FileUpload1.SaveAs(Server.MapPath("~/Images/" + fullname));
Image1.ImageUrl = "~/Images/" + fullname;
}
Monday, February 27, 2012
Wednesday, February 22, 2012
Generate Unique Identity Value Using Datepart in SQLServer :
create procedure SP_Insert_Customer
as
begin
declare @CustomerID nvarchar(50)
set @CustomerID=CONVERT(nvarchar(10),DATEPART(MM,getdate()))+ CONVERT(nvarchar(10),DATEPART(YYYY,getdate()))
+ CONVERT(nvarchar(10),(select COUNT(*) from dbo.Users)+ 1)
print(@ID);
end
O/P:220124 i.e Month Year Number of rows in the table
as
begin
declare @CustomerID nvarchar(50)
set @CustomerID=CONVERT(nvarchar(10),DATEPART(MM,getdate()))+ CONVERT(nvarchar(10),DATEPART(YYYY,getdate()))
+ CONVERT(nvarchar(10),(select COUNT(*) from dbo.Users)+ 1)
print(@ID);
end
O/P:220124 i.e Month Year Number of rows in the table
Monday, February 20, 2012
Get Identity column value after Inserting the record into Database Table
Create procedure [dbo].[SP_Insert_Employee]
@EmpId int output,
@Name nvarchar(50),
@Address nvarchar(50),
as
begin
insert into dbo.Employee(Name,Address) values(@Name,@Address )
set @EmpId=SCOPE_IDENTITY();
end
@EmpId int output,
@Name nvarchar(50),
@Address nvarchar(50),
as
begin
insert into dbo.Employee(Name,Address) values(@Name,@Address )
set @EmpId=SCOPE_IDENTITY();
end
Thursday, February 16, 2012
Hide part webpage when the webpage was printing
PrintForm = function (strid)
{
var prtContent = document.getElementById(strid);
var WinPrint = window.open('', '', 'letf=0,top=0,width=480,height=400,toolbar=0,scrollbars=0,status=0');
WinPrint.document.write(prtContent.innerHTML);
WinPrint.document.close();
WinPrint.focus();
WinPrint.print();
WinPrint.close();
prtContent.innerHTML = strOldOne;
}
Here’s the webpage, the printable area must be inside a div:
<div id="divPrint">
SAMPLE CONTENT
</div>
<input id="btnPrintBottom" type="button" value="Print" onclick="PrintForm('divPrint')" />
Print button hiding:
document.getElementById('Button').style.visibility = "hidden";
Display TextBox data into Label :
var b = document.getElementById('<%=TextBox1.ClientID %>').value;
document.getElementById('lb').style.display = "block";
var c = document.getElementById('<%=lblName.ClientID %>').innerText= b.toString();
Wednesday, February 15, 2012
Copy data from one Textbox to another Textbox while User entering data
on the keypress event of the textbox write the following code
document.getElementByID('<%=TextBox2.ClientID%>').Text = document.getElementByID('<%=TextBox1.ClientID%>').Text <asp:textbox id="TextBox" runat=server onkeypress="document.getElementByID('<%=TextBox2.ClientID%>').Text = document.getElementByID('<%=TextBox1.ClientID%>').Text"> </asp:textbox> onblur event of the textbox write the following code //javaScript function fnFromToTextBox(firstTxtBox,secondTxtBox) { secondTxtBox.value=firstTxtBox.value; } //on Code behind txtCompany.Attributes.Add("onblur", "fnFromToTextBox(txtCompany,txtBilling)"); Using Keyup: <asp:TextBox id="TextBox1" onkeyup="document.getElementById("TextBox2").value = this.value;"></asp:TextBox>
document.getElementByID('<%=TextBox2.ClientID%>').Text = document.getElementByID('<%=TextBox1.ClientID%>').Text <asp:textbox id="TextBox" runat=server onkeypress="document.getElementByID('<%=TextBox2.ClientID%>').Text = document.getElementByID('<%=TextBox1.ClientID%>').Text"> </asp:textbox> onblur event of the textbox write the following code //javaScript function fnFromToTextBox(firstTxtBox,secondTxtBox) { secondTxtBox.value=firstTxtBox.value; } //on Code behind txtCompany.Attributes.Add("onblur", "fnFromToTextBox(txtCompany,txtBilling)"); Using Keyup: <asp:TextBox id="TextBox1" onkeyup="document.getElementById("TextBox2").value = this.value;"></asp:TextBox>
Tuesday, February 14, 2012
textbox validation Using JQuery
<script language="javascript" type="text/javascript">
$(document).ready(function ()
{
$("#<% =btnSubmit.ClientID %>").click(function ()
{
if (jQuery.trim($("#<%=txtBranchCode.ClientID %>").val()) == "")
{
alert("Please enter branch code..");
$("#<%=txtBranchCode.ClientID %>").focus();
return false;
} });
$("#<% =btnCancel.ClientID %>").click(function ()
{
$("#<%=txtBranchCode.ClientID %>").val("");
return false;
});
});
</script>
$(document).ready(function ()
{
$("#<% =btnSubmit.ClientID %>").click(function ()
{
if (jQuery.trim($("#<%=txtBranchCode.ClientID %>").val()) == "")
{
alert("Please enter branch code..");
$("#<%=txtBranchCode.ClientID %>").focus();
return false;
} });
$("#<% =btnCancel.ClientID %>").click(function ()
{
$("#<%=txtBranchCode.ClientID %>").val("");
return false;
});
});
</script>
Monday, February 13, 2012
Image Upload Local folder(project folder) and Save image path into data baes
string onlyname = string.Empty;
int isExist;
if (imgupload.HasFile)
{
string categoryname = txtCategoryName.Text;
string imagename = categoryname.Replace(" ", "");
imagename= imagename + "_Left";
string filePath = imgupload.FileName;
string filename = filePath.Substring(filePath.LastIndexOf("\\") + 1);
string[] filetype = filename.Split('.');
onlyname = imagename + "." + filetype[1];
imgupload.SaveAs(Server.MapPath("~/images/inner/") + onlyname);
lblmsg.Text = "Upload status: File uploaded!";
}
int isExist;
if (imgupload.HasFile)
{
string categoryname = txtCategoryName.Text;
string imagename = categoryname.Replace(" ", "");
imagename= imagename + "_Left";
string filePath = imgupload.FileName;
string filename = filePath.Substring(filePath.LastIndexOf("\\") + 1);
string[] filetype = filename.Split('.');
onlyname = imagename + "." + filetype[1];
imgupload.SaveAs(Server.MapPath("~/images/inner/") + onlyname);
lblmsg.Text = "Upload status: File uploaded!";
}
Subscribe to:
Posts (Atom)